render / rpms / libvirt

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