render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 09fdcd8662d3153e6c4c68864edc89b5f39ae169 Mon Sep 17 00:00:00 2001
Message-Id: <09fdcd8662d3153e6c4c68864edc89b5f39ae169@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 18 Feb 2014 11:50:32 +0100
Subject: [PATCH] qemuBuildNicDevStr: Set vectors= on Multiqueue

https://bugzilla.redhat.com/show_bug.cgi?id=1066209

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.

(cherry picked from commit 4f588a1b465e2b32c78429e8d2f2c010eb11da19)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Conflicts:
	src/qemu/qemu_command.c: Context as 54a77c6d is not backported yet
Signed-off-by: Jiri Denemark <jdenemar@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 b5729a4..e6a6650 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4811,7 +4811,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
                    virDomainNetDefPtr net,
                    int vlan,
                    int bootindex,
-                   bool multiqueue,
+                   int vhostfdSize,
                    virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4864,8 +4864,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
@@ -7407,10 +7410,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 39da555..06c4b30 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -106,7 +106,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 d9ce951..a3c291d 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.9.0