libvirt/SOURCES/libvirt-qemu-don-t-use-chardev-FD-passing-for-vhostuser-backend.patch
2021-10-08 13:11:11 +00:00

172 lines
6.8 KiB
Diff

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