From 893a8a0b2313e2634e86fc8dd754957ee6caada4 Mon Sep 17 00:00:00 2001
Message-Id: <893a8a0b2313e2634e86fc8dd754957ee6caada4.1377873642.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 22 Aug 2013 15:24:42 +0200
Subject: [PATCH] qemuBuildNicDevStr: Add mq=on for multiqueue networking
https://bugzilla.redhat.com/show_bug.cgi?id=651941
If user requested multiqueue networking, beside multiple /dev/tap and
/dev/vhost-net openings, we forgot to pass mq=on onto the -device
virtio-net-pci command line. This is advised at:
http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature
(cherry picked from commit 4c2d0b29d7790df55d12216a56dbf0b29bcb00e3)
---
src/qemu/qemu_command.c | 8 +++++++-
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_hotplug.c | 5 ++++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 43934f1..af8a5b4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4730,6 +4730,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
+ bool multiqueue,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4782,6 +4783,8 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainVirtioEventIdxTypeToString(net->driver.virtio.event_idx));
}
}
+ if (usingVirtio && multiqueue)
+ virBufferAddLit(&buf, ",mq=on");
if (vlan == -1)
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
else
@@ -7275,7 +7278,10 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virCommandAddArgList(cmd, "-netdev", host, NULL);
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, qemuCaps)))
+ bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
+
+ if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
+ multiqueue, qemuCaps)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
} else {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 5c5c025..a9854a3 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,6 +102,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
+ bool multiqueue,
virQEMUCapsPtr qemuCaps);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index cbe7072..b1f4586 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -859,7 +859,10 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, priv->qemuCaps)))
+ bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
+
+ if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
+ multiqueue, priv->qemuCaps)))
goto try_remove;
} else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
--
1.8.3.2