gnome-boxes: Coder’s log 3

July, 24th – August, 8th

For the ones that aren’t avid readers of my blog or just missed out on my last blog post, two weeks ago I talked about the fact that I managed to implement connection sharing in GNOME-Boxes.

As a follow up, some underlying mechanisms have changed, as I introduced two new classes to libvirt-gconfig which represent the hardware ability of a display to be advertised on the network (an abstract class which represents a listen child node
of the graphics device and a derived class which represents a listen child node of type address). This change of plans happened because of the need to only support the preferred XML format for a machine, namely the graphics device’s newly added listen nodes and not the old listen attribute.

I did my best to further refine the UI of the new feature, to try to get it rid of any potential bugs and to organize and improve the 20+ patches as best as possible (although I rushed a little at the end, because it felt like a never ending task and I was very excited to start further implement other stuff 🙂 ).  I won’t post another video with this feature for now, but don’t worry as I will definitely post a demonstration of it when it reaches its final form.


Last blog post I also talked about starting working on the SPICE layers. I won’t try to pose as the brave hero, as I was a little intimidated at first by the multitude of components working together. After quickly figuring out how the SPICE layers work, I realized that I had nothing to be afraid of and accomplishments also came along.

Firstly, let’s talk about my strategy of implementing multiple shared folders on top of the already implemented single shared folder. I am planning to make the SPICE session handle as many shared folders as the number of WebDAV channels present in the XML (analogous to the way multiple USB devices redirection is implemented).  This has one disadvantage, the fact that after adding more shared folder than previously provided, the machines needs a restart. However, the user would only need a restart when increasing the number of shared folders comparing to the previous configuration and  this can be avoided  by enabling by default a decent number of shared folders. Advantages are more numerous and include intuitiveness, simplicity and making more use of the existing, tested code.

Now, for the progress. The first step was to change the way the  SPICE server detects WebDAV channels, in order to be able to create WebDAV channels with different port names than the current default one, “org.spice-space.webdav.0”.

The second step was to modify phodav’s spice-webdavd server, to support listening for multiple  shared folder connections. In order to achieve this, I took some baby steps:

  • I did a much needed code refactoring, as the code didn’t appear to be designed for multiple shared folders.
  • I encapsulated the data that would represent one shared folder server/connection in a ‘Channel’ structure and further changed a lot of the method’s signatures, for them to be able to operate on a specific instance of a ‘Channel’.
  • As a final baby step, I added a method that can count the available number of WebDAV channels, in order to only listen for the right number of connections.

I then tested it using two channels and, after some seg faults and a few headaches, it worked 🙂 .

Although multiple connections establish successfully, the client part of SPICE isn’t yet prepared to handle multiple shared folders, so both receive the same folder to access. After reading so much text until now, I’m sure you deserve a picture:



Further steps are preparing the client layer of SPICE to handle the multiple shared folders and to integrate the whole feature with Boxes. This probably won’t take a lot of time and I could also start working on using SSH to connect to the SPICE display of a remote libvirt box ( ).

4 thoughts on “gnome-boxes: Coder’s log 3

  1. Wouldn’t it be more reasonable for the user to expose only a single mount point with a all the shared folders inside? One way to achieve this is to have the spice client share a private folder (say ~/.config/boxes/shared-folders) that contains links to the shared folders. The other way would be to modify phodav to export multiple folders. Either of this two options are simpler imho, and don’t require protocol, server, or config changes. No waste of sockets either.

    Regarding the spice-webdavd daemon, it’s quite a hack honestly, and the plan would be to move away from virtio-serial to a more upcoming suitable transport vsock. The vsock patches are in the kernel now, qemu patches are under review. Thers is interesting work needed for the Spice “port” channel to handle that. Then the ugly webdavd and client mux/demux code could hopefully be removed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s