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