From 0676a072651491d167aa66e56f4ce5eef036ac14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 6 Jul 2018 11:30:33 +0100 Subject: [PATCH] Fix regressions in chardev handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel P. Berrangé --- ...devStdioLogd-param-from-vhostuser-co.patch | 94 ++++++ ...-parameters-of-qemuBuildChrChardevSt.patch | 308 ++++++++++++++++++ ...hardev-FD-passing-for-vhostuser-back.patch | 166 ++++++++++ ...cket-chardevs-operating-in-client-mo.patch | 123 +++++++ libvirt.spec | 9 +- 5 files changed, 699 insertions(+), 1 deletion(-) create mode 100644 0001-qemu-remove-chardevStdioLogd-param-from-vhostuser-co.patch create mode 100644 0002-qemu-consolidate-parameters-of-qemuBuildChrChardevSt.patch create mode 100644 0003-qemu-don-t-use-chardev-FD-passing-for-vhostuser-back.patch create mode 100644 0004-qemu-fix-UNIX-socket-chardevs-operating-in-client-mo.patch diff --git a/0001-qemu-remove-chardevStdioLogd-param-from-vhostuser-co.patch b/0001-qemu-remove-chardevStdioLogd-param-from-vhostuser-co.patch new file mode 100644 index 0000000..a037d36 --- /dev/null +++ b/0001-qemu-remove-chardevStdioLogd-param-from-vhostuser-co.patch @@ -0,0 +1,94 @@ +From 4c76266baca407ae4981a180aed45193e50a8ade Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Thu, 5 Jul 2018 11:59:22 +0100 +Subject: [PATCH 1/4] qemu: remove chardevStdioLogd param from vhostuser code + path +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The vhostuser network backend is only supported with the UNIX domain +socket chardev backend, so passing around chardevStdioLogd is not +required. + +Signed-off-by: Daniel P. Berrangé +--- + src/qemu/qemu_command.c | 20 +++++++------------- + 1 file changed, 7 insertions(+), 13 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 04c5c28438..9351b9fddb 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -8195,8 +8195,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + virDomainDefPtr def, + virDomainNetDefPtr net, + virQEMUCapsPtr qemuCaps, +- unsigned int bootindex, +- bool chardevStdioLogd) ++ unsigned int bootindex) + { + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + char *chardev = NULL; +@@ -8217,7 +8216,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + cmd, cfg, def, + net->data.vhostuser, + net->info.alias, qemuCaps, false, +- chardevStdioLogd))) ++ false))) + goto cleanup; + break; + +@@ -8291,8 +8290,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + virNetDevVPortProfileOp vmop, + bool standalone, + size_t *nnicindexes, +- int **nicindexes, +- bool chardevStdioLogd) ++ int **nicindexes) + { + int ret = -1; + char *nic = NULL, *host = NULL; +@@ -8415,8 +8413,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + ret = qemuBuildVhostuserCommandLine(driver, logManager, secManager, cmd, def, +- net, qemuCaps, bootindex, +- chardevStdioLogd); ++ net, qemuCaps, bootindex); + goto cleanup; + break; + +@@ -8600,8 +8597,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, + bool standalone, + size_t *nnicindexes, + int **nicindexes, +- unsigned int *bootHostdevNet, +- bool chardevStdioLogd) ++ unsigned int *bootHostdevNet) + { + size_t i; + int last_good_net = -1; +@@ -8628,8 +8624,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, + if (qemuBuildInterfaceCommandLine(driver, logManager, secManager, cmd, def, net, + qemuCaps, bootNet, vmop, + standalone, nnicindexes, +- nicindexes, +- chardevStdioLogd) < 0) ++ nicindexes) < 0) + goto error; + + last_good_net = i; +@@ -10290,8 +10285,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, + + if (qemuBuildNetCommandLine(driver, logManager, secManager, cmd, def, + qemuCaps, vmop, standalone, +- nnicindexes, nicindexes, &bootHostdevNet, +- chardevStdioLogd) < 0) ++ nnicindexes, nicindexes, &bootHostdevNet) < 0) + goto error; + + if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, +-- +2.17.1 + diff --git a/0002-qemu-consolidate-parameters-of-qemuBuildChrChardevSt.patch b/0002-qemu-consolidate-parameters-of-qemuBuildChrChardevSt.patch new file mode 100644 index 0000000..d874344 --- /dev/null +++ b/0002-qemu-consolidate-parameters-of-qemuBuildChrChardevSt.patch @@ -0,0 +1,308 @@ +From 0140d4c59b7fb26432b520bb7e85bd6834f560b0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Wed, 4 Jul 2018 14:20:40 +0100 +Subject: [PATCH 2/4] qemu: consolidate parameters of qemuBuildChrChardevStr + into flags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There are two boolean parameters passed to qemuBuildChrChardevStr, +and soon there will be a third. It will be clearer to understand +from callers' POV if we use named flags instead. + +Signed-off-by: Daniel P. Berrangé +--- + src/qemu/qemu_command.c | 94 ++++++++++++++++++++++++++--------------- + 1 file changed, 61 insertions(+), 33 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 9351b9fddb..63c7ac0f82 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -4935,6 +4935,12 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) + return -1; + } + ++ ++enum { ++ QEMU_BUILD_CHARDEV_TCP_NOWAIT = (1 << 0), ++ QEMU_BUILD_CHARDEV_FILE_LOGD = (1 << 1), ++}; ++ + /* This function outputs a -chardev command line option which describes only the + * host side of the character device */ + static char * +@@ -4946,8 +4952,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + const virDomainChrSourceDef *dev, + const char *alias, + virQEMUCapsPtr qemuCaps, +- bool nowait, +- bool chardevStdioLogd) ++ unsigned int flags) + { + virBuffer buf = VIR_BUFFER_INITIALIZER; + bool telnet; +@@ -4986,7 +4991,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + _("append not supported in this QEMU binary")); + goto cleanup; + } +- if (qemuBuildChrChardevFileStr(chardevStdioLogd ? logManager : NULL, ++ if (qemuBuildChrChardevFileStr(flags & QEMU_BUILD_CHARDEV_FILE_LOGD ? ++ logManager : NULL, + cmd, def, &buf, + "path", dev->data.file.path, + "append", dev->data.file.append) < 0) +@@ -5032,8 +5038,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + dev->data.tcp.service, + telnet ? ",telnet" : ""); + +- if (dev->data.tcp.listen) +- virBufferAdd(&buf, nowait ? ",server,nowait" : ",server", -1); ++ if (dev->data.tcp.listen) { ++ virBufferAddLit(&buf, ",server"); ++ if (flags & QEMU_BUILD_CHARDEV_TCP_NOWAIT) ++ virBufferAddLit(&buf, ",nowait"); ++ } + + qemuBuildChrChardevReconnectStr(&buf, &dev->data.tcp.reconnect); + +@@ -5091,8 +5100,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + virBufferAsprintf(&buf, "socket,id=%s,path=", charAlias); + virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path); + } +- if (dev->data.nix.listen) +- virBufferAdd(&buf, nowait ? ",server,nowait" : ",server", -1); ++ if (dev->data.nix.listen) { ++ virBufferAddLit(&buf, ",server"); ++ if (flags & QEMU_BUILD_CHARDEV_TCP_NOWAIT) ++ virBufferAddLit(&buf, ",nowait"); ++ } + + qemuBuildChrChardevReconnectStr(&buf, &dev->data.nix.reconnect); + break; +@@ -5426,6 +5438,9 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, + qemuDomainObjPrivatePtr priv) + { + char *chrdev; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (priv->chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + if (!priv->monConfig) + return 0; +@@ -5433,8 +5448,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, + if (!(chrdev = qemuBuildChrChardevStr(logManager, secManager, + cmd, cfg, def, + priv->monConfig, "monitor", +- priv->qemuCaps, true, +- priv->chardevStdioLogd))) ++ priv->qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, chrdev); +@@ -5559,6 +5573,9 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, + char **chr, + bool chardevStdioLogd) + { ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + *chr = NULL; + + switch ((virDomainRNGBackend) rng->backend) { +@@ -5571,8 +5588,8 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, + if (!(*chr = qemuBuildChrChardevStr(logManager, secManager, + cmd, cfg, def, + rng->source.chardev, +- rng->info.alias, qemuCaps, true, +- chardevStdioLogd))) ++ rng->info.alias, qemuCaps, ++ cdevflags))) + return -1; + } + +@@ -8215,8 +8232,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + if (!(chardev = qemuBuildChrChardevStr(logManager, secManager, + cmd, cfg, def, + net->data.vhostuser, +- net->info.alias, qemuCaps, false, +- false))) ++ net->info.alias, qemuCaps, 0))) + goto cleanup; + break; + +@@ -8696,6 +8712,9 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, + virBuffer opt = VIR_BUFFER_INITIALIZER; + const char *database; + const char *contAlias = NULL; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + if (!def->nsmartcards) + return 0; +@@ -8761,8 +8780,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + smartcard->data.passthru, + smartcard->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) { ++ qemuCaps, cdevflags))) { + virBufferFreeAndReset(&opt); + return -1; + } +@@ -8930,6 +8948,9 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *devstr = NULL; + int rc; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + if (shmem->size) { + /* +@@ -8993,8 +9014,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, + devstr = qemuBuildChrChardevStr(logManager, secManager, + cmd, cfg, def, + &shmem->server.chr, +- shmem->info.alias, qemuCaps, true, +- chardevStdioLogd); ++ shmem->info.alias, qemuCaps, ++ cdevflags); + if (!devstr) + return -1; + +@@ -9087,6 +9108,9 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, + { + size_t i; + bool havespice = false; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + if (def->nserials) { + for (i = 0; i < def->ngraphics && !havespice; i++) { +@@ -9106,8 +9130,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + serial->source, + serial->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9148,6 +9171,9 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, + bool chardevStdioLogd) + { + size_t i; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + for (i = 0; i < def->nparallels; i++) { + virDomainChrDefPtr parallel = def->parallels[i]; +@@ -9157,8 +9183,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + parallel->source, + parallel->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9183,6 +9208,9 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, + bool chardevStdioLogd) + { + size_t i; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + for (i = 0; i < def->nchannels; i++) { + virDomainChrDefPtr channel = def->channels[i]; +@@ -9194,8 +9222,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + channel->source, + channel->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9212,8 +9239,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + channel->source, + channel->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9239,6 +9265,9 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + bool chardevStdioLogd) + { + size_t i; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + /* Explicit console devices */ + for (i = 0; i < def->nconsoles; i++) { +@@ -9257,8 +9286,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + console->source, + console->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9279,8 +9307,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + console->source, + console->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9295,8 +9322,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + console->source, + console->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) ++ qemuCaps, cdevflags))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9419,6 +9445,9 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, + bool chardevStdioLogd) + { + size_t i; ++ unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; ++ if (chardevStdioLogd) ++ cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; + + for (i = 0; i < def->nredirdevs; i++) { + virDomainRedirdevDefPtr redirdev = def->redirdevs[i]; +@@ -9428,8 +9457,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, + cmd, cfg, def, + redirdev->source, + redirdev->info.alias, +- qemuCaps, true, +- chardevStdioLogd))) { ++ qemuCaps, cdevflags))) { + return -1; + } + +-- +2.17.1 + diff --git a/0003-qemu-don-t-use-chardev-FD-passing-for-vhostuser-back.patch b/0003-qemu-don-t-use-chardev-FD-passing-for-vhostuser-back.patch new file mode 100644 index 0000000..ee97a05 --- /dev/null +++ b/0003-qemu-don-t-use-chardev-FD-passing-for-vhostuser-back.patch @@ -0,0 +1,166 @@ +From ed5aa85f371aebb0103e712f9a103d011ab9ae43 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Wed, 4 Jul 2018 14:28:14 +0100 +Subject: [PATCH 3/4] 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 + +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é +--- + 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 63c7ac0f82..82d8030a33 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -4939,6 +4939,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 +@@ -5082,7 +5083,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); +@@ -5438,7 +5440,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; + +@@ -5573,7 +5576,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; +@@ -8712,7 +8716,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; + +@@ -8948,7 +8953,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; + +@@ -9108,7 +9114,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; + +@@ -9171,7 +9178,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; + +@@ -9208,7 +9216,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; + +@@ -9265,7 +9274,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; + +@@ -9445,7 +9455,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.17.1 + diff --git a/0004-qemu-fix-UNIX-socket-chardevs-operating-in-client-mo.patch b/0004-qemu-fix-UNIX-socket-chardevs-operating-in-client-mo.patch new file mode 100644 index 0000000..91fc15f --- /dev/null +++ b/0004-qemu-fix-UNIX-socket-chardevs-operating-in-client-mo.patch @@ -0,0 +1,123 @@ +From 1dd55b2fcddecf22a046b1df069b55fdfe17af76 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Fri, 6 Jul 2018 11:00:11 +0100 +Subject: [PATCH 4/4] qemu: fix UNIX socket chardevs operating in client mode +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When support was adding for passing a pre-opened listener socket to UNIX +chardevs, it accidentally passed the listener socket for client mode +chardevs too with predictable amounts of fail resulting. + +Expand the unit test coverage to validate that we are only doing FD +passing when operating in server mode. + +Reported-by: Richard W.M. Jones +Signed-off-by: Daniel P. Berrangé +--- + src/qemu/qemu_command.c | 3 +- + .../qemuxml2argvdata/serial-unix-chardev.args | 2 ++ + .../serial-unix-chardev.x86_64-latest.args | 36 +++++++++++++++++++ + .../qemuxml2argvdata/serial-unix-chardev.xml | 4 +++ + tests/qemuxml2argvtest.c | 1 + + 5 files changed, 45 insertions(+), 1 deletion(-) + create mode 100644 tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 82d8030a33..32eb59b6ab 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -5083,7 +5083,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: +- if ((flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) && ++ if (dev->data.nix.listen && ++ (flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) { + if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0) + goto cleanup; +diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.args b/tests/qemuxml2argvdata/serial-unix-chardev.args +index 584f4a1dd1..873d3263c6 100644 +--- a/tests/qemuxml2argvdata/serial-unix-chardev.args ++++ b/tests/qemuxml2argvdata/serial-unix-chardev.args +@@ -26,4 +26,6 @@ server,nowait \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ + -chardev socket,id=charserial0,path=/tmp/serial.sock \ + -device isa-serial,chardev=charserial0,id=serial0 \ ++-chardev socket,id=charserial1,path=/tmp/serial-server.sock,server,nowait \ ++-device isa-serial,chardev=charserial1,id=serial1 \ + -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 +diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args +new file mode 100644 +index 0000000000..ce7a7f80d7 +--- /dev/null ++++ b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args +@@ -0,0 +1,36 @@ ++LC_ALL=C \ ++PATH=/bin \ ++HOME=/home/test \ ++USER=test \ ++LOGNAME=test \ ++QEMU_AUDIO_DRV=none \ ++/usr/bin/qemu-system-i686 \ ++-name guest=QEMUGuest1,debug-threads=on \ ++-S \ ++-object secret,id=masterKey0,format=raw,\ ++file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ ++-machine pc,accel=tcg,usb=off,dump-guest-core=off \ ++-m 214 \ ++-realtime mlock=off \ ++-smp 1,sockets=1,cores=1,threads=1 \ ++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ ++-display none \ ++-no-user-config \ ++-nodefaults \ ++-chardev socket,id=charmonitor,fd=1729,server,nowait \ ++-mon chardev=charmonitor,id=monitor,mode=control \ ++-rtc base=utc \ ++-no-shutdown \ ++-no-acpi \ ++-boot strict=on \ ++-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ ++-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ ++-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ ++-chardev socket,id=charserial0,path=/tmp/serial.sock \ ++-device isa-serial,chardev=charserial0,id=serial0 \ ++-chardev socket,id=charserial1,fd=1729,server,nowait \ ++-device isa-serial,chardev=charserial1,id=serial1 \ ++-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ ++-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ ++resourcecontrol=deny \ ++-msg timestamp=on +diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.xml b/tests/qemuxml2argvdata/serial-unix-chardev.xml +index 04f83779ce..af513d6445 100644 +--- a/tests/qemuxml2argvdata/serial-unix-chardev.xml ++++ b/tests/qemuxml2argvdata/serial-unix-chardev.xml +@@ -25,6 +25,10 @@ + + + ++ ++ ++ ++ + + + +diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c +index 2d52f352b0..3be5af03aa 100644 +--- a/tests/qemuxml2argvtest.c ++++ b/tests/qemuxml2argvtest.c +@@ -1335,6 +1335,7 @@ mymain(void) + QEMU_CAPS_CHARDEV_FILE_APPEND); + DO_TEST("serial-unix-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL); ++ DO_TEST_CAPS_LATEST("serial-unix-chardev"); + DO_TEST("serial-tcp-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL); + DO_TEST("serial-udp-chardev", +-- +2.17.1 + diff --git a/libvirt.spec b/libvirt.spec index 64b6119..260aec3 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -252,7 +252,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 4.5.0 -Release: 1%{?dist}%{?extra_release} +Release: 2%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -260,6 +260,10 @@ URL: https://libvirt.org/ %define mainturl stable_updates/ %endif Source: https://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz +Patch1: 0001-qemu-remove-chardevStdioLogd-param-from-vhostuser-co.patch +Patch2: 0002-qemu-consolidate-parameters-of-qemuBuildChrChardevSt.patch +Patch3: 0003-qemu-don-t-use-chardev-FD-passing-for-vhostuser-back.patch +Patch4: 0004-qemu-fix-UNIX-socket-chardevs-operating-in-client-mo.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2129,6 +2133,9 @@ exit 0 %changelog +* Fri Jul 6 2018 Daniel P. Berrangé - 4.5.0-2 +- Fix regressions with chardev handling + * Tue Jul 3 2018 Daniel P. Berrangé - 4.5.0-1 - Update to 4.5.0 release