[gnome-boxes/gnome-3-14] vm-configurator: Replace user iface w/ bridge for existing domains



commit b2a6e97f00af5f989879a207c3bb0152d2ed8a34
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Oct 1 18:51:49 2014 +0100

    vm-configurator: Replace user iface w/ bridge for existing domains
    
    While we update configuration of existing domains, lets also replace the
    slow user network interface device with faster bridge device (if its
    available).

 src/vm-configurator.vala |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 62af0ee..44d6db3 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -239,6 +239,27 @@ private class Boxes.VMConfigurator {
         } catch (GLib.Error e) {
             warning ("Failed to update CPU config for '%s': %s", domain.name, e.message);
         }
+
+        if (!is_libvirt_bridge_net_available ())
+            return;
+
+        // First remove user interface device
+        GLib.List<GVirConfig.DomainDevice> devices = null;
+        DomainInterfaceUser iface = null;
+        foreach (var device in domain.get_devices ()) {
+            if (device is DomainInterfaceUser)
+                iface = device as DomainInterfaceUser;
+            else
+                devices.prepend (device);
+        }
+        devices.reverse ();
+        domain.set_devices (devices);
+
+        // If user interface device was found and removed, let's add bridge device now.
+        if (iface != null) {
+            var virtio = iface.get_model () == "virtio";
+            add_network_interface (domain, true, virtio);
+        }
     }
 
     private static void set_target_media_config (Domain domain, string target_path, InstallerMedia 
install_media) {


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