render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 1b3ded7e3b24f927a7941178e2bb75d1d8052c3f Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <1b3ded7e3b24f927a7941178e2bb75d1d8052c3f@dist-git>
99cbc7
From: Laine Stump <laine@redhat.com>
99cbc7
Date: Mon, 16 Sep 2019 09:54:06 -0400
99cbc7
Subject: [PATCH] qemu: call common NetDef validation for hotplug and device
99cbc7
 update
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
qemuDomainAttachNetDevice() (hotplug) previously had some of the
99cbc7
validation that is in qemuDomainValidateActualNetDef(), but it was
99cbc7
incomplete. qemuDomainChangeNet() had none of that validation, but it
99cbc7
is all appropriate in both cases.
99cbc7
99cbc7
This is the final piece of a previously partial resolution to
99cbc7
https://bugzilla.redhat.com/1502754
99cbc7
99cbc7
Signed-off-by: Laine Stump <laine@redhat.com>
99cbc7
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit 70a29b378a397f6f4571c95b9d3cbba711a90859)
99cbc7
99cbc7
Signed-off-by: Laine Stump <laine@redhat.com>
99cbc7
Message-Id: <20190916135406.18523-4-laine@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_hotplug.c | 32 ++++++++------------------------
99cbc7
 1 file changed, 8 insertions(+), 24 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index ca8b0aaf62..3b888e31b9 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -848,32 +848,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
99cbc7
     if (virDomainNetAllocateActualDevice(vm->def, net) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    actualType = virDomainNetGetActualType(net);
99cbc7
-
99cbc7
-    /* Currently only TAP/macvtap devices supports multiqueue. */
99cbc7
-    if (net->driver.virtio.queues > 0 &&
99cbc7
-        !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_DIRECT ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_ETHERNET ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) {
99cbc7
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
99cbc7
-                       _("Multiqueue network is not supported for: %s"),
99cbc7
-                       virDomainNetTypeToString(actualType));
99cbc7
+    /* final validation now that we have full info on the type */
99cbc7
+    if (qemuDomainValidateActualNetDef(net, priv->qemuCaps) < 0)
99cbc7
         return -1;
99cbc7
-    }
99cbc7
 
99cbc7
-    /* and only TAP devices support nwfilter rules */
99cbc7
-    if (net->filter &&
99cbc7
-        !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
99cbc7
-          actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
99cbc7
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
99cbc7
-                       _("filterref is not supported for "
99cbc7
-                         "network interfaces of type %s"),
99cbc7
-                       virDomainNetTypeToString(actualType));
99cbc7
-        return -1;
99cbc7
-    }
99cbc7
+    actualType = virDomainNetGetActualType(net);
99cbc7
 
99cbc7
     if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
99cbc7
         goto cleanup;
99cbc7
@@ -3154,6 +3133,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
99cbc7
                     virDomainObjPtr vm,
99cbc7
                     virDomainDeviceDefPtr dev)
99cbc7
 {
99cbc7
+    qemuDomainObjPrivatePtr priv = vm->privateData;
99cbc7
     virDomainNetDefPtr newdev = dev->data.net;
99cbc7
     virDomainNetDefPtr *devslot = NULL;
99cbc7
     virDomainNetDefPtr olddev;
99cbc7
@@ -3333,6 +3313,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
99cbc7
         goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
+    /* final validation now that we have full info on the type */
99cbc7
+    if (qemuDomainValidateActualNetDef(newdev, priv->qemuCaps) < 0)
99cbc7
+        goto cleanup;
99cbc7
+
99cbc7
     newType = virDomainNetGetActualType(newdev);
99cbc7
 
99cbc7
     if (newType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
99cbc7
-- 
99cbc7
2.23.0
99cbc7