c401cc
From 09fdcd8662d3153e6c4c68864edc89b5f39ae169 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <09fdcd8662d3153e6c4c68864edc89b5f39ae169@dist-git>
c401cc
From: Michal Privoznik <mprivozn@redhat.com>
c401cc
Date: Tue, 18 Feb 2014 11:50:32 +0100
c401cc
Subject: [PATCH] qemuBuildNicDevStr: Set vectors= on Multiqueue
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1066209
c401cc
c401cc
Yet another advice appeared on the Multiqueue wiki page:
c401cc
c401cc
http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature
c401cc
c401cc
We should add vectors=N onto the qemu command line, where
c401cc
N = 2 * (number of queues) + 1.
c401cc
c401cc
(cherry picked from commit 4f588a1b465e2b32c78429e8d2f2c010eb11da19)
c401cc
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c401cc
c401cc
Conflicts:
c401cc
	src/qemu/qemu_command.c: Context as 54a77c6d is not backported yet
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_command.c | 13 +++++++------
c401cc
 src/qemu/qemu_command.h |  2 +-
c401cc
 src/qemu/qemu_hotplug.c |  4 +---
c401cc
 3 files changed, 9 insertions(+), 10 deletions(-)
c401cc
c401cc
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c401cc
index b5729a4..e6a6650 100644
c401cc
--- a/src/qemu/qemu_command.c
c401cc
+++ b/src/qemu/qemu_command.c
c401cc
@@ -4811,7 +4811,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
c401cc
                    virDomainNetDefPtr net,
c401cc
                    int vlan,
c401cc
                    int bootindex,
c401cc
-                   bool multiqueue,
c401cc
+                   int vhostfdSize,
c401cc
                    virQEMUCapsPtr qemuCaps)
c401cc
 {
c401cc
     virBuffer buf = VIR_BUFFER_INITIALIZER;
c401cc
@@ -4864,8 +4864,11 @@ qemuBuildNicDevStr(virDomainDefPtr def,
c401cc
                               virDomainVirtioEventIdxTypeToString(net->driver.virtio.event_idx));
c401cc
         }
c401cc
     }
c401cc
-    if (usingVirtio && multiqueue)
c401cc
-        virBufferAddLit(&buf, ",mq=on");
c401cc
+    if (usingVirtio && vhostfdSize > 1) {
c401cc
+        /* As advised at http://www.linux-kvm.org/page/Multiqueue
c401cc
+         * we should add vectors=2*N+1 where N is the vhostfdSize */
c401cc
+        virBufferAsprintf(&buf, ",mq=on,vectors=%d", 2 * vhostfdSize + 1);
c401cc
+    }
c401cc
     if (vlan == -1)
c401cc
         virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
c401cc
     else
c401cc
@@ -7407,10 +7410,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
c401cc
         virCommandAddArgList(cmd, "-netdev", host, NULL);
c401cc
     }
c401cc
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
c401cc
-        bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
c401cc
-
c401cc
         if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
c401cc
-                                       multiqueue, qemuCaps)))
c401cc
+                                       vhostfdSize, qemuCaps)))
c401cc
             goto cleanup;
c401cc
         virCommandAddArgList(cmd, "-device", nic, NULL);
c401cc
     } else {
c401cc
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
c401cc
index 39da555..06c4b30 100644
c401cc
--- a/src/qemu/qemu_command.h
c401cc
+++ b/src/qemu/qemu_command.h
c401cc
@@ -106,7 +106,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
c401cc
                           virDomainNetDefPtr net,
c401cc
                           int vlan,
c401cc
                           int bootindex,
c401cc
-                          bool multiqueue,
c401cc
+                          int vhostfdSize,
c401cc
                           virQEMUCapsPtr qemuCaps);
c401cc
 
c401cc
 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
c401cc
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c401cc
index d9ce951..a3c291d 100644
c401cc
--- a/src/qemu/qemu_hotplug.c
c401cc
+++ b/src/qemu/qemu_hotplug.c
c401cc
@@ -859,10 +859,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
c401cc
     }
c401cc
 
c401cc
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
c401cc
-        bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
c401cc
-
c401cc
         if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
c401cc
-                                          multiqueue, priv->qemuCaps)))
c401cc
+                                          vhostfdSize, priv->qemuCaps)))
c401cc
             goto try_remove;
c401cc
     } else {
c401cc
         if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
c401cc
-- 
c401cc
1.9.0
c401cc