[PATCH 19/37] qemuBuildNicDevProps: Don't pass 'vhostfdSize'

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

 



All callers effectively pass 'net->driver.virtio.queues'. In case of the
code in 'qemu_hotplug.c' this value was set to '1' if it was 0 before.

Since 'qemuBuildNicDevProps' only uses it if it's greater than 1 we can
remove all the extra complexity.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c |  7 +++----
 src/qemu/qemu_command.h |  1 -
 src/qemu/qemu_hotplug.c | 12 +-----------
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fc8e209976..78ea638c26 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4075,7 +4075,6 @@ qemuBuildLegacyNicStr(virDomainNetDef *net)
 virJSONValue *
 qemuBuildNicDevProps(virDomainDef *def,
                      virDomainNetDef *net,
-                     size_t vhostfdSize,
                      virQEMUCaps *qemuCaps)
 {
     g_autoptr(virJSONValue) props = NULL;
@@ -4112,7 +4111,7 @@ qemuBuildNicDevProps(virDomainDef *def,
             }
         }

-        if (vhostfdSize > 1) {
+        if (net->driver.virtio.queues > 1) {
             if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
                 /* ccw provides a one to one relation of fds to queues and
                  * does not support the vectors option
@@ -4123,7 +4122,7 @@ qemuBuildNicDevProps(virDomainDef *def,
                  * we should add vectors=2*N+2 where N is the vhostfdSize
                  */
                 mq = VIR_TRISTATE_SWITCH_ON;
-                vectors = 2 * vhostfdSize + 2;
+                vectors = 2 * net->driver.virtio.queues + 2;
             }
         }

@@ -8987,7 +8986,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
         if (qemuCommandAddExtDevice(cmd, &net->info, def, qemuCaps) < 0)
             goto cleanup;

-        if (!(nicprops = qemuBuildNicDevProps(def, net, net->driver.virtio.queues, qemuCaps)))
+        if (!(nicprops = qemuBuildNicDevProps(def, net, qemuCaps)))
             goto cleanup;
         if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, def, qemuCaps) < 0)
             goto cleanup;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index cae0541445..3b487a647c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,7 +102,6 @@ qemuBuildInterfaceConnect(virDomainObj *vm,
 virJSONValue *
 qemuBuildNicDevProps(virDomainDef *def,
                      virDomainNetDef *net,
-                     size_t vhostfdSize,
                      virQEMUCaps *qemuCaps);

 char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 28868cf3d0..90ca35bccf 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1191,7 +1191,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
     char **vhostfdName = NULL;
     int *vhostfd = NULL;
     size_t vhostfdSize = 0;
-    size_t queueSize = 0;
     g_autoptr(virJSONValue) nicprops = NULL;
     g_autoptr(virJSONValue) netprops = NULL;
     int ret = -1;
@@ -1287,7 +1286,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         tapfdSize = vhostfdSize = net->driver.virtio.queues;
         if (!tapfdSize)
             tapfdSize = vhostfdSize = 1;
-        queueSize = tapfdSize;
         tapfd = g_new0(int, tapfdSize);
         memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
         vhostfd = g_new0(int, vhostfdSize);
@@ -1304,7 +1302,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         tapfdSize = vhostfdSize = net->driver.virtio.queues;
         if (!tapfdSize)
             tapfdSize = vhostfdSize = 1;
-        queueSize = tapfdSize;
         tapfd = g_new0(int, tapfdSize);
         memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
         vhostfd = g_new0(int, vhostfdSize);
@@ -1322,7 +1319,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         tapfdSize = vhostfdSize = net->driver.virtio.queues;
         if (!tapfdSize)
             tapfdSize = vhostfdSize = 1;
-        queueSize = tapfdSize;
         tapfd = g_new0(int, tapfdSize);
         memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
         vhostfd = g_new0(int, vhostfdSize);
@@ -1336,9 +1332,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         break;

     case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
-        queueSize = net->driver.virtio.queues;
-        if (!queueSize)
-            queueSize = 1;
         if (!qemuDomainSupportsNicdev(vm->def, net)) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "%s", _("Nicdev support unavailable"));
@@ -1388,9 +1381,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         break;

     case VIR_DOMAIN_NET_TYPE_VDPA:
-        queueSize = net->driver.virtio.queues;
-        if (!queueSize)
-            queueSize = 1;
         if (qemuDomainAdjustMaxMemLock(vm, false) < 0)
             goto cleanup;
         adjustmemlock = true;
@@ -1506,7 +1496,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
     for (i = 0; i < vhostfdSize; i++)
         VIR_FORCE_CLOSE(vhostfd[i]);

-    if (!(nicprops = qemuBuildNicDevProps(vm->def, net, queueSize, priv->qemuCaps)))
+    if (!(nicprops = qemuBuildNicDevProps(vm->def, net, priv->qemuCaps)))
         goto try_remove;

     qemuDomainObjEnterMonitor(driver, vm);
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux