]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuBuildNicDevStr: Set vectors= on Multiqueue
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 23 Aug 2013 07:48:24 +0000 (09:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 9 Jan 2014 14:23:57 +0000 (15:23 +0100)
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.

src/qemu/qemu_command.c
src/qemu/qemu_command.h
src/qemu/qemu_hotplug.c

index 35b7c6759a2620eb7d6e186deab3974d1436e6d1..81486df80afd94550cd74bb9925dea151d9f7bed 100644 (file)
@@ -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 {
index 66c23cc47875be3c977f7fe747d89ba876ee97cf..de7683d80977518797b7668d049e859dd1554e28 100644 (file)
@@ -105,7 +105,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
                           virDomainNetDefPtr net,
                           int vlan,
                           int bootindex,
-                          bool multiqueue,
+                          int vhostfdSize,
                           virQEMUCapsPtr qemuCaps);
 
 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
index 7a8caf1f43d2963c488803170f7649cc3d6c5ad0..4315df2a5c761cbb72c47fda8c95fd88c740b661 100644 (file)
@@ -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)))