[libvirt PATCH 08/10] qemu: support updating <portOptions isolated='yes|no'/> during device update

Laine Stump laine at redhat.com
Mon Feb 17 04:22:57 UTC 2020


This setting can be updating very easily on an already active
interface by just changing it in sysfs. If the bridge used for
connection is also changed, there is no need to separately update it,
because the new setting isf done as a part of connecting to the bridge
anyway.

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/qemu/qemu_hotplug.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index af892255c7..9800491755 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3481,6 +3481,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
     bool needBandwidthSet = false;
     bool needCoalesceChange = false;
     bool needVlanUpdate = false;
+    bool needIsolatedPortChange = false;
     int ret = -1;
     int changeidx = -1;
     g_autoptr(virConnect) conn = NULL;
@@ -3805,6 +3806,11 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
         needVlanUpdate = true;
     }
 
+    if (virDomainNetGetActualPortOptionsIsolated(olddev) !=
+        virDomainNetGetActualPortOptionsIsolated(newdev)) {
+        needIsolatedPortChange = true;
+    }
+
     if (olddev->linkstate != newdev->linkstate)
         needLinkStateChange = true;
 
@@ -3851,6 +3857,20 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
          * determined that the rest of newdev is equivalent to olddev,
          * so move newdev into place */
         needReplaceDevDef = true;
+
+        /* this is already updated as a part of reconnecting the bridge */
+        needIsolatedPortChange = false;
+    }
+
+    if (needIsolatedPortChange) {
+        const char *bridge = virDomainNetGetActualBridgeName(newdev);
+        bool isolatedOn = (virDomainNetGetActualPortOptionsIsolated(newdev) ==
+                           VIR_TRISTATE_BOOL_YES);
+
+        if (virNetDevBridgePortSetIsolated(bridge, newdev->ifname, isolatedOn) < 0)
+            goto cleanup;
+
+        needReplaceDevDef = true;
     }
 
     if (needFilterChange) {
-- 
2.24.1




More information about the libvir-list mailing list