gnome-boxes: Introducing shared folders

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.

spice-webdavd for Windows

spice-webdavd for Linux

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.

Screenshot from 2017-06-15 13-20-06

  • 3rd step: Access the shared folders from inside the guest machine

Screenshot from 2017-06-15 16-06-15

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 !

Screenshot from 2017-06-15 16-11-21

 

 

A big thank you to everybody who has helped me implement this feature: Zeeshan Ali, Felipe Borges, Victor Toso, Fabiano Fidencio and Cristophe Fergeau

26 thoughts on “gnome-boxes: Introducing shared folders

  1. spice-webdavd has never worked reliably on windows, at least for me (it would crash immediately while starting the service), and last I checked it hadn’t seen any updates in a long time; was it updated recently to fix the crash?
    Otherwise you can’t really claim the feature, if windows support is not there.

    Liked by 1 person

    1. Giovani, which windows and spice-webdavd are you using?

      I remember Lukáš did some work on webdav while I was still working on SPICE and it used to work (at that time).

      Maybe you re hitting https://bugzilla.gnome.org/show_bug.cgi?id=781979 … would you mind confirming this (in the bugzilla) or open a new bug in case you’re seeing something different?

      Buona Giornata!

      Like

  2. My gnome-boxes (3.24.0, with libvirt 3.2.1 and spice-webdavd 2.1) does not show the “Folder Sharing” section in the properties page. Am I doing something wrong?

    Like

    1. same here I suspect windows file sharing and/or firewall issues – have installed the latest spice-webdavd but I can not select any folder “locally” – playing around with settings.
      Could it be we need to change network interface from “realtek” to “virtio” for this to work? Default during install is realtek…

      Like

      1. I got Windows 10 x64 now working on a fedora 27 guest with boxes 3.26.2
        The trick was to remove anything from spice from the guest and then reinstall the latest spice guest tools from there https://www.spice-space.org/download/windows/spice-guest-tools/ and install the x86 (not x64) from there https://www.spice-space.org/download/windows/spice-webdavd/ . Works also with windows defender enabled.
        It seems spice has problems when guest tools are x86 and webdavd is x64.

        Like

  3. I Played around with this for work – a problem is that it is abysmally slow, at least for me on first setup. WebDAV is a much slower protocol than Samba, and I would prefer if Samba was used instead, especially given that IIRC qemu basically has a built in samba server that works via command line, which Gnome Boxes could use under the hood. Hopefully this can get fixed in the future, this is otherwise a very nice virtual machine tool!

    Like

  4. Has anybody the same problem, that adding a shared folder from Fedora 28 host to a Windows 10 guest only works if you go in the Properties -> Devices & Shares tab of the VM and save the shared folder a further time everytime you boot up Windows 10?
    Otherwise Windows 10 only shows me a “System Volume Information” folder inside the DavWWWroot “partition”.

    Like

  5. Does not work for me at all on ubuntu 19.10 with gnome boxes. spice folder is there but it fails to open with an https error connection refused

    Like

    1. Same for me with Fedora 32 guest on Ubuntu 20.4 host. Spice folder is there on client but it fails to open with an https error connection refused

      Like

      1. It was reported as #5 “https://gitlab.gnome.org/GNOME/phodav/-/issues?scope=all&utf8=%E2%9C%93&state=closed” and the workround is, Quote:
        “Connect to server” -> enter dav://localhost:9843/ for spice shared folder or dav://localhost:8080/ for chezdav>

        Like

Leave a comment