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