[gnome-boxes/wip/fix-clones-regression-conflict-with-iface: 2/3] vm-configurator: Rework logic for when we recreate network interface




commit 7a0e659e4233bde29a86d56d2891450150485f1f
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Sep 16 15:09:01 2021 +0200

    vm-configurator: Rework logic for when we recreate network interface
    
    In commit 8a336ba0 we started to recreate the network interface only
    when the bridge was available and the existing domain network interface
    was "user".
    
    That's correct but we also should recreate the network interface when
    there isn't a bridge available and the existing domain network interface
    was "bridge".
    
    This fixes the issue of when the virbr0 network interface was availale
    during the VM creation but is no longer available afterwards.

 src/vm-configurator.vala | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 02b01758..b9b515d1 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -310,11 +310,20 @@ else if (device is DomainDisk) {
             devices.prepend (new DomainGraphicsVnc ());
         }
 
-        // If user interface device was found and it needs to be bridged
         if (iface != null) {
             var bridge = is_libvirt_bridge_net_available ();
-            if (bridge && (iface is DomainInterfaceUser)) {
-                var virtio = iface.get_model () == "virtio";
+            var virtio = iface.get_model () == "virtio";
+
+            /* We recreate the network interface if:
+             *  1. There's a bridge but the interface is "user"
+             *  2. There isn't a bridge but the interface is "bridge"
+             *  3. We are cloning the VM (the MAC address shouldn't collide)
+             *
+             * Otherwise, we keep the existing network interface.
+             */
+            if ((bridge && (iface is DomainInterfaceUser)) ||
+                (!bridge && (iface is DomainInterfaceBridge)) ||
+                VMConfigurator.is_libvirt_cloning_config (domain)) {
 
                 devices.prepend (create_network_interface (domain, bridge, virtio));
             } else {


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