99cbc7
From 9e76cc4f94818d6193611fc0dcb6d661e71ba493 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <9e76cc4f94818d6193611fc0dcb6d661e71ba493@dist-git>
99cbc7
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
99cbc7
Date: Fri, 6 Jul 2018 15:47:01 +0100
99cbc7
Subject: [PATCH] qemu: don't use chardev FD passing for vhostuser backend
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1597940
99cbc7
99cbc7
QEMU chardevs have a bug which makes the vhostuser backend complain
99cbc7
about lack of support for FD passing when validating the chardev.
99cbc7
While this is ultimately QEMU's responsibility to fix, libvirt needs to
99cbc7
avoid tickling the bug.
99cbc7
99cbc7
Simply disabling chardev FD passing just for vhostuser's chardev is
99cbc7
the most prudent approach, avoiding need for a QEMU version number
99cbc7
check.
99cbc7
99cbc7
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
99cbc7
(cherry picked from commit ed5aa85f371aebb0103e712f9a103d011ab9ae43)
99cbc7
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_command.c                   | 31 +++++++++++++++--------
99cbc7
 tests/qemuxml2argvdata/net-vhostuser.args |  3 +--
99cbc7
 tests/qemuxml2argvtest.c                  |  2 +-
99cbc7
 3 files changed, 23 insertions(+), 13 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
99cbc7
index 0c3ce98caf..637e787d25 100644
99cbc7
--- a/src/qemu/qemu_command.c
99cbc7
+++ b/src/qemu/qemu_command.c
99cbc7
@@ -4938,6 +4938,7 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
99cbc7
 enum {
99cbc7
     QEMU_BUILD_CHARDEV_TCP_NOWAIT = (1 << 0),
99cbc7
     QEMU_BUILD_CHARDEV_FILE_LOGD  = (1 << 1),
99cbc7
+    QEMU_BUILD_CHARDEV_UNIX_FD_PASS = (1 << 2),
99cbc7
 };
99cbc7
 
99cbc7
 /* This function outputs a -chardev command line option which describes only the
99cbc7
@@ -5081,7 +5082,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
99cbc7
         break;
99cbc7
 
99cbc7
     case VIR_DOMAIN_CHR_TYPE_UNIX:
99cbc7
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
99cbc7
+        if ((flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
99cbc7
+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
99cbc7
             if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0)
99cbc7
                 goto cleanup;
99cbc7
             int fd = qemuOpenChrChardevUNIXSocket(dev);
99cbc7
@@ -5437,7 +5439,8 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager,
99cbc7
                             qemuDomainObjPrivatePtr priv)
99cbc7
 {
99cbc7
     char *chrdev;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (priv->chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -5572,7 +5575,8 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
99cbc7
                              char **chr,
99cbc7
                              bool chardevStdioLogd)
99cbc7
 {
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
     *chr = NULL;
99cbc7
@@ -8740,7 +8744,8 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
99cbc7
     virBuffer opt = VIR_BUFFER_INITIALIZER;
99cbc7
     const char *database;
99cbc7
     const char *contAlias = NULL;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -8976,7 +8981,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
99cbc7
     virBuffer buf = VIR_BUFFER_INITIALIZER;
99cbc7
     char *devstr = NULL;
99cbc7
     int rc;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -9136,7 +9142,8 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
99cbc7
 {
99cbc7
     size_t i;
99cbc7
     bool havespice = false;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -9199,7 +9206,8 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
99cbc7
                               bool chardevStdioLogd)
99cbc7
 {
99cbc7
     size_t i;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -9236,7 +9244,8 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
99cbc7
                              bool chardevStdioLogd)
99cbc7
 {
99cbc7
     size_t i;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -9293,7 +9302,8 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
99cbc7
                             bool chardevStdioLogd)
99cbc7
 {
99cbc7
     size_t i;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
@@ -9473,7 +9483,8 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
99cbc7
                              bool chardevStdioLogd)
99cbc7
 {
99cbc7
     size_t i;
99cbc7
-    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT;
99cbc7
+    unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
99cbc7
+        QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
99cbc7
     if (chardevStdioLogd)
99cbc7
         cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD;
99cbc7
 
99cbc7
diff --git a/tests/qemuxml2argvdata/net-vhostuser.args b/tests/qemuxml2argvdata/net-vhostuser.args
99cbc7
index fc4557a1f2..513fc535ab 100644
99cbc7
--- a/tests/qemuxml2argvdata/net-vhostuser.args
99cbc7
+++ b/tests/qemuxml2argvdata/net-vhostuser.args
99cbc7
@@ -14,8 +14,7 @@ QEMU_AUDIO_DRV=none \
99cbc7
 -display none \
99cbc7
 -no-user-config \
99cbc7
 -nodefaults \
99cbc7
--chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
99cbc7
-server,nowait \
99cbc7
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
99cbc7
 -mon chardev=charmonitor,id=monitor,mode=control \
99cbc7
 -rtc base=utc \
99cbc7
 -no-shutdown \
99cbc7
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
99cbc7
index d6911f9344..2d52f352b0 100644
99cbc7
--- a/tests/qemuxml2argvtest.c
99cbc7
+++ b/tests/qemuxml2argvtest.c
99cbc7
@@ -1266,7 +1266,7 @@ mymain(void)
99cbc7
     DO_TEST("misc-no-reboot", NONE);
99cbc7
     DO_TEST("misc-uuid", NONE);
99cbc7
     DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
99cbc7
-    DO_TEST("net-vhostuser", NONE);
99cbc7
+    DO_TEST("net-vhostuser", QEMU_CAPS_CHARDEV_FD_PASS);
99cbc7
     DO_TEST("net-vhostuser-multiq",
99cbc7
             QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
99cbc7
     DO_TEST_FAILURE("net-vhostuser-multiq", NONE);
99cbc7
-- 
99cbc7
2.18.0
99cbc7