[PATCH 1/4] qemu: update vlan tag of macvtap (direct) passthrough devices during update-device

Laine Stump via Devel posted 4 patches 2 weeks, 3 days ago
[PATCH 1/4] qemu: update vlan tag of macvtap (direct) passthrough devices during update-device
Posted by Laine Stump via Devel 2 weeks, 3 days ago
From: Laine Stump <laine@redhat.com>

We already update the vlan tag of interfaces that are attached to an
OVS bridge or Linux host bridge. This patch adds the bit of code
necessary to update the vlan tag of a macvtap passthrough interface
(the only other type of interface that supports vlan tagging).

Resolves: https://issues.redhat.com/browse/RHEL-74487
Resolves: https://issues.redhat.com/browse/RHEL-7300
Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/qemu/qemu_hotplug.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index fccbef5d0c..6d20e3a850 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4265,11 +4265,21 @@ qemuDomainChangeNet(virQEMUDriver *driver,
              */
             if (virNetDevOpenvswitchUpdateVlan(newdev->ifname, &newdev->vlan) < 0)
                 goto cleanup;
-        } else {
+        } else if (newType == VIR_DOMAIN_NET_TYPE_DIRECT &&
+                   virDomainNetGetActualDirectMode(newdev) == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
+            if (virNetDevSetNetConfig(virDomainNetGetActualDirectDev(newdev),
+                                      -1, NULL, virDomainNetGetActualVlan(newdev), NULL, true) < 0) {
+                goto cleanup;
+            }
+        } else if (newBridgeName) {
              /* vlan setup is done as a part of reconnecting the tap
               * device to a new bridge (either OVS or Linux host bridge).
               */
             needBridgeChange = true;
+        } else {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                           _("unable to change vlan on '%1$s' network type"),
+                           virDomainNetTypeToString(newType));
         }
         needReplaceDevDef = true;
     }
-- 
2.52.0