[PATCH] qemuBuildNicDevStr: Set vectors= on Multiqueue

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

 



Yet another advice appeared on the Multiqueue wiki page:

http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature

We should add vectors=N onto the qemu command line, where
N = 2 * (number of queues) + 1.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 13 +++++++------
 src/qemu/qemu_command.h |  2 +-
 src/qemu/qemu_hotplug.c |  4 +---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b5ac15a..dbfa0dc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4730,7 +4730,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
                    virDomainNetDefPtr net,
                    int vlan,
                    int bootindex,
-                   bool multiqueue,
+                   int vhostfdSize,
                    virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4783,8 +4783,11 @@ qemuBuildNicDevStr(virDomainDefPtr def,
                               virDomainVirtioEventIdxTypeToString(net->driver.virtio.event_idx));
         }
     }
-    if (usingVirtio && multiqueue)
-        virBufferAddLit(&buf, ",mq=on");
+    if (usingVirtio && vhostfdSize > 1) {
+        /* As advised at http://www.linux-kvm.org/page/Multiqueue
+         * we should add vectors=2*N+1 where N is the vhostfdSize */
+        virBufferAsprintf(&buf, ",mq=on,vectors=%d", 2 * vhostfdSize + 1);
+    }
     if (vlan == -1)
         virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
     else
@@ -7278,10 +7281,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
         virCommandAddArgList(cmd, "-netdev", host, NULL);
     }
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-        bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
-
         if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
-                                       multiqueue, qemuCaps)))
+                                       vhostfdSize, qemuCaps)))
             goto cleanup;
         virCommandAddArgList(cmd, "-device", nic, NULL);
     } else {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index a9854a3..4761705 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,7 +102,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
                           virDomainNetDefPtr net,
                           int vlan,
                           int bootindex,
-                          bool multiqueue,
+                          int vhostfdSize,
                           virQEMUCapsPtr qemuCaps);
 
 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9727410..3491fd6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -859,10 +859,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
     }
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
-
         if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
-                                          multiqueue, priv->qemuCaps)))
+                                          vhostfdSize, priv->qemuCaps)))
             goto try_remove;
     } else {
         if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]