[libvirt] [PATCH] qemuBuildNicDevStr: Add mq=on for multiqueue networking

Michal Privoznik mprivozn at redhat.com
Thu Aug 22 08:36:35 UTC 2013


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
---

Notes:
    Maybe worth backporting to maintainer branches too. The MQ was introduced in
    the 1.0.6 release.

 src/qemu/qemu_command.c | 7 ++++++-
 src/qemu/qemu_command.h | 1 +
 src/qemu/qemu_hotplug.c | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f151173..d73872a 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,9 @@ 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 478f331..b49073b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -859,7 +859,9 @@ 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.1.5




More information about the libvir-list mailing list