[gnome-boxes] vm-configurator: Ensure WebDAV channel existence



commit 164dd20ab00c95bda7f9bdfbcd64bd52c5ba2deb
Author: Visarion Alexandru <viorel visarion gmail com>
Date:   Sun May 14 22:55:37 2017 +0300

    vm-configurator: Ensure WebDAV channel existence
    
    We have to make sure that the WebDAV channel always exists in the
    machine's XML configuration file, for the planned shared folders
    feature to work on local machines.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730259

 src/vm-configurator.vala |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 4933398..38207a8 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -11,6 +11,7 @@ private class Boxes.VMConfigurator {
     private const string BOXES_NS = "boxes";
     private const string BOXES_NS_URI = Config.PACKAGE_URL;
     private const string BOXES_OLD_NS_URI = "http://live.gnome.org/Boxes/";;
+    private const string WEBDAV_CHANNEL_URI = "org.spice-space.webdav.0";
     private const string BOXES_XML = "<gnome-boxes>%s</gnome-boxes>";
     private const string LIVE_STATE = "live";
     private const string INSTALLATION_STATE = "installation";
@@ -85,6 +86,10 @@ private class Boxes.VMConfigurator {
         channel.set_source (vmc);
         domain.add_device (channel);
 
+        // Webdav channel. This is needed for the shared folder feature to work.
+        var webdav_channel = create_webdav_channel ();
+        domain.add_device (webdav_channel);
+
         add_usb_support (domain);
         add_smartcard_support (domain);
 
@@ -256,11 +261,18 @@ private class Boxes.VMConfigurator {
         GLib.List<GVirConfig.DomainDevice> devices = null;
         DomainInterface iface = null;
         DomainGraphicsSpice graphics = null;
+        DomainChannel channel_webdav = null;
         foreach (var device in domain.get_devices ()) {
             if (device is DomainInterface)
                 iface = device as DomainInterface;
             else if (device is DomainGraphicsSpice)
                 graphics = device as DomainGraphicsSpice;
+            else if (device is DomainChannel) {
+                var device_channel = device as DomainChannel;
+                if (device_channel.get_target_name () == WEBDAV_CHANNEL_URI)
+                    channel_webdav = device_channel;
+                devices.prepend (device);
+            }
             else
                 devices.prepend (device);
         }
@@ -275,6 +287,8 @@ private class Boxes.VMConfigurator {
 
         if (graphics != null)
             devices.prepend (create_graphics_device ());
+        if (channel_webdav == null)
+            devices.prepend (create_webdav_channel ());
 
         devices.reverse ();
         domain.set_devices (devices);
@@ -520,6 +534,18 @@ private class Boxes.VMConfigurator {
         return graphics;
     }
 
+    public static DomainChannel create_webdav_channel () {
+        var channel_webdav = new DomainChannel ();
+        channel_webdav.set_target_type (DomainChannelTargetType.VIRTIO);
+        channel_webdav.set_target_name (WEBDAV_CHANNEL_URI);
+
+        var spice_port = new DomainChardevSourceSpicePort ();
+        spice_port.set_channel (WEBDAV_CHANNEL_URI);
+        channel_webdav.set_source (spice_port);
+
+        return channel_webdav;
+    }
+
     private static DomainControllerUsb create_usb_controller (DomainControllerUsbModel model,
                                                               DomainControllerUsb?     master = null,
                                                               uint                     index = 0,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]