Blame SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-vhostuser-handling-a-bit-further.patch

c8c376
From 620a22d4292138a3c3591df9196416bed56b0316 Mon Sep 17 00:00:00 2001
c8c376
Message-Id: <620a22d4292138a3c3591df9196416bed56b0316@dist-git>
c8c376
From: Michal Privoznik <mprivozn@redhat.com>
c8c376
Date: Tue, 8 Nov 2016 13:42:04 +0100
c8c376
Subject: [PATCH] qemuBuildInterfaceCommandLine: Move vhostuser handling a bit
c8c376
 further
c8c376
c8c376
RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108
c8c376
RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032
c8c376
c8c376
The idea is to have function that does some checking of the
c8c376
arguments at its beginning and then have one big switch for all
c8c376
the interface types it supports. Each one of them generating the
c8c376
corresponding part of the command line.
c8c376
c8c376
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c8c376
(cherry picked from commit 4a74ccdb92fd2103392b177c38846b685e141840)
c8c376
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c8c376
---
c8c376
 src/qemu/qemu_command.c                            |  9 +++---
c8c376
 .../qemuxml2argv-net-vhostuser-fail.xml            | 36 ++++++++++++++++++++++
c8c376
 tests/qemuxml2argvtest.c                           |  3 ++
c8c376
 3 files changed, 44 insertions(+), 4 deletions(-)
c8c376
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml
c8c376
c8c376
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c8c376
index 1e7d9209a..a9b91213d 100644
c8c376
--- a/src/qemu/qemu_command.c
c8c376
+++ b/src/qemu/qemu_command.c
c8c376
@@ -8004,15 +8004,13 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
c8c376
     if (!bootindex)
c8c376
         bootindex = net->info.bootIndex;
c8c376
 
c8c376
-    if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
c8c376
-        return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex);
c8c376
-
c8c376
     /* Currently nothing besides TAP devices supports multiqueue. */
c8c376
     if (net->driver.virtio.queues > 0 &&
c8c376
         !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
c8c376
           actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
c8c376
           actualType == VIR_DOMAIN_NET_TYPE_DIRECT ||
c8c376
-          actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
c8c376
+          actualType == VIR_DOMAIN_NET_TYPE_ETHERNET ||
c8c376
+          actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) {
c8c376
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c8c376
                        _("Multiqueue network is not supported for: %s"),
c8c376
                        virDomainNetTypeToString(actualType));
c8c376
@@ -8092,6 +8090,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
c8c376
          */
c8c376
         ret = 0;
c8c376
         goto cleanup;
c8c376
+    } else if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
c8c376
+        ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex);
c8c376
+        goto cleanup;
c8c376
     }
c8c376
 
c8c376
     /* For types whose implementations use a netdev on the host, add
c8c376
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml
c8c376
new file mode 100644
c8c376
index 000000000..e9fe14f75
c8c376
--- /dev/null
c8c376
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml
c8c376
@@ -0,0 +1,36 @@
c8c376
+<domain type='qemu'>
c8c376
+  <name>QEMUGuest1</name>
c8c376
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
c8c376
+  <memory unit='KiB'>219136</memory>
c8c376
+  <currentMemory unit='KiB'>219136</currentMemory>
c8c376
+  <vcpu placement='static'>1</vcpu>
c8c376
+  <os>
c8c376
+    <type arch='i686' machine='pc'>hvm</type>
c8c376
+    <boot dev='hd'/>
c8c376
+  </os>
c8c376
+  <clock offset='utc'/>
c8c376
+  <on_poweroff>destroy</on_poweroff>
c8c376
+  <on_reboot>restart</on_reboot>
c8c376
+  <on_crash>destroy</on_crash>
c8c376
+  <devices>
c8c376
+    <emulator>/usr/bin/qemu</emulator>
c8c376
+    <disk type='block' device='disk'>
c8c376
+      <driver name='qemu' type='raw'/>
c8c376
+      <source dev='/dev/HostVG/QEMUGuest1'/>
c8c376
+      <target dev='hda' bus='ide'/>
c8c376
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
c8c376
+    </disk>
c8c376
+    <controller type='usb' index='0'/>
c8c376
+    <controller type='ide' index='0'/>
c8c376
+    <controller type='pci' index='0' model='pci-root'/>
c8c376
+    <interface type='vhostuser'>
c8c376
+      <mac address='52:54:00:ee:96:6b'/>
c8c376
+      <source type='unix' path='/tmp/vhost0.sock' mode='server'/>
c8c376
+      <model type='virtio'/>
c8c376
+      <filterref filter='myfilter'/>
c8c376
+      <backend tap='/dev/mytap'/>
c8c376
+      <driver queues='4'/>
c8c376
+    </interface>
c8c376
+    <memballoon model='none'/>
c8c376
+  </devices>
c8c376
+</domain>
c8c376
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c8c376
index d84c148df..f48632b70 100644
c8c376
--- a/tests/qemuxml2argvtest.c
c8c376
+++ b/tests/qemuxml2argvtest.c
c8c376
@@ -1028,6 +1028,9 @@ mymain(void)
c8c376
     DO_TEST("net-vhostuser-multiq",
c8c376
             QEMU_CAPS_NETDEV, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
c8c376
     DO_TEST_FAILURE("net-vhostuser-multiq", QEMU_CAPS_NETDEV);
c8c376
+    DO_TEST_FAILURE("net-vhostuser-fail",
c8c376
+                    QEMU_CAPS_NETDEV,
c8c376
+                    QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
c8c376
     DO_TEST("net-user", NONE);
c8c376
     DO_TEST("net-virtio", NONE);
c8c376
     DO_TEST("net-virtio-device",
c8c376
-- 
c8c376
2.11.0
c8c376