In this blog post I’ll talk a little about the motivation behind shared folders in gnome-boxes and the challenges encountered while implementing it. I will also make sure to post a few UI pictures, alongside a very short guide for those of you eager to test this fresh out of the oven feature.
1. Motivation
Being able to share a directory between the host machine and a guest machine is, needless to say, a very convenient way of accessing files from one another. Thanks to the SPICE developers, an API is available which is capable of doing just that. (the only conditions are that the guest machine must have a SPICE display and the spice-webdavd service installed). Considering this, the decision of further implementing shared folders in gnome-boxes is certainly not one to think about twice.
2. Challenges
The first challenge was to implement *multiple* shared folders, considering that the underlying library only supports a *single* shared folder. After many discussions, we followed Marc-Andre Lureau’s suggestion of simply creating symlinks for every shared folder inside a config directory, which is the one eventually shared trough SPICE.
The second challenge was assuring the persistence of shared folders. Once the user has shared a directory, it must remain shared even after restarting the guest machine, GNOME-Boxes or the host machine. Following Felipe Borges’s suggestion, I used Gsettings and Variants, which is a great way of accomplishing tasks like this.
3. Short guide and UI pictures
Since this feature is meant to be as out-of-the-box as possible, the guide is more of a demonstration rather than a tutorial. Enjoy!
- 1st step: Install the spice-webdavd service in the guest machine.
The Linux version can also be installed from the official repositories.
- 2nd step: Play with the new Properties -> ‘Devices & Shares’ section, in GNOME-Boxes.
Make use of the newly added UI in order to choose which folders belonging to the host machine need to be shared with the guest machine.
Note: if no shared folders are selected, the Public folder is shared by default.
- 3rd step: Access the shared folders from inside the guest machine
In case the “Spice client folder” device doesn’t show up at first, make sure to refresh the file manager.
- 4th step: Have some fun !
A big thank you to everybody who has helped me implement this feature: Zeeshan Ali, Felipe Borges, Victor Toso, Fabiano Fidencio and Cristophe Fergeau