[libvirt] [PATCH RESEND] qemuBuildNicDevStr: Set vectors= on Multiqueue

Michal Privoznik mprivozn at redhat.com
Wed Jan 8 14:22:45 UTC 2014


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 at redhat.com>
---
 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 35b7c67..81486df 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4980,7 +4980,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
                    virDomainNetDefPtr net,
                    int vlan,
                    int bootindex,
-                   bool multiqueue,
+                   int vhostfdSize,
                    virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -5035,8 +5035,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
@@ -7591,10 +7594,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
         virCommandAddArgList(cmd, "-netdev", host, NULL);
     }
     if (qemuDomainSupportsNicdev(def, qemuCaps, net)) {
-        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 66c23cc..de7683d 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -105,7 +105,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 7a8caf1..4315df2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -998,10 +998,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.5.1




More information about the libvir-list mailing list