|
|
982648 |
From 0d80657c5002e3914f28dce9bf46c2a6577e817b Mon Sep 17 00:00:00 2001
|
|
|
982648 |
Message-Id: <0d80657c5002e3914f28dce9bf46c2a6577e817b@dist-git>
|
|
|
982648 |
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
|
|
982648 |
Date: Fri, 6 Jul 2018 15:47:02 +0100
|
|
|
982648 |
Subject: [PATCH] qemu: fix UNIX socket chardevs operating in client mode
|
|
|
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=1598440
|
|
|
982648 |
|
|
|
982648 |
When support was adding for passing a pre-opened listener socket to UNIX
|
|
|
982648 |
chardevs, it accidentally passed the listener socket for client mode
|
|
|
982648 |
chardevs too with predictable amounts of fail resulting. This affects
|
|
|
982648 |
libvirt when using QEMU >= 2.12
|
|
|
982648 |
|
|
|
982648 |
Expand the unit test coverage to validate that we are only doing FD
|
|
|
982648 |
passing when operating in server mode.
|
|
|
982648 |
|
|
|
982648 |
https://bugzilla.redhat.com/show_bug.cgi?id=1598440
|
|
|
982648 |
|
|
|
982648 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
982648 |
Reported-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
982648 |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
982648 |
(cherry picked from commit 1bc1a7e3205f7ef75ebd8fd1ef7653f8e181e3d2)
|
|
|
982648 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
982648 |
---
|
|
|
982648 |
src/qemu/qemu_command.c | 3 +-
|
|
|
982648 |
.../qemuxml2argvdata/serial-unix-chardev.args | 2 ++
|
|
|
982648 |
.../serial-unix-chardev.x86_64-latest.args | 36 +++++++++++++++++++
|
|
|
982648 |
.../qemuxml2argvdata/serial-unix-chardev.xml | 4 +++
|
|
|
982648 |
tests/qemuxml2argvtest.c | 1 +
|
|
|
982648 |
5 files changed, 45 insertions(+), 1 deletion(-)
|
|
|
982648 |
create mode 100644 tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
|
|
|
982648 |
|
|
|
982648 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
982648 |
index 637e787d25..f38ae668a7 100644
|
|
|
982648 |
--- a/src/qemu/qemu_command.c
|
|
|
982648 |
+++ b/src/qemu/qemu_command.c
|
|
|
982648 |
@@ -5082,7 +5082,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
|
|
|
982648 |
break;
|
|
|
982648 |
|
|
|
982648 |
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
|
|
982648 |
- if ((flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
|
|
|
982648 |
+ if (dev->data.nix.listen &&
|
|
|
982648 |
+ (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 |
diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.args b/tests/qemuxml2argvdata/serial-unix-chardev.args
|
|
|
982648 |
index 584f4a1dd1..873d3263c6 100644
|
|
|
982648 |
--- a/tests/qemuxml2argvdata/serial-unix-chardev.args
|
|
|
982648 |
+++ b/tests/qemuxml2argvdata/serial-unix-chardev.args
|
|
|
982648 |
@@ -26,4 +26,6 @@ server,nowait \
|
|
|
982648 |
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
|
|
982648 |
-chardev socket,id=charserial0,path=/tmp/serial.sock \
|
|
|
982648 |
-device isa-serial,chardev=charserial0,id=serial0 \
|
|
|
982648 |
+-chardev socket,id=charserial1,path=/tmp/serial-server.sock,server,nowait \
|
|
|
982648 |
+-device isa-serial,chardev=charserial1,id=serial1 \
|
|
|
982648 |
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
|
|
982648 |
diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
|
|
|
982648 |
new file mode 100644
|
|
|
982648 |
index 0000000000..ce7a7f80d7
|
|
|
982648 |
--- /dev/null
|
|
|
982648 |
+++ b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
|
|
|
982648 |
@@ -0,0 +1,36 @@
|
|
|
982648 |
+LC_ALL=C \
|
|
|
982648 |
+PATH=/bin \
|
|
|
982648 |
+HOME=/home/test \
|
|
|
982648 |
+USER=test \
|
|
|
982648 |
+LOGNAME=test \
|
|
|
982648 |
+QEMU_AUDIO_DRV=none \
|
|
|
982648 |
+/usr/bin/qemu-system-i686 \
|
|
|
982648 |
+-name guest=QEMUGuest1,debug-threads=on \
|
|
|
982648 |
+-S \
|
|
|
982648 |
+-object secret,id=masterKey0,format=raw,\
|
|
|
982648 |
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
|
|
982648 |
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
|
|
|
982648 |
+-m 214 \
|
|
|
982648 |
+-realtime mlock=off \
|
|
|
982648 |
+-smp 1,sockets=1,cores=1,threads=1 \
|
|
|
982648 |
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
|
|
982648 |
+-display none \
|
|
|
982648 |
+-no-user-config \
|
|
|
982648 |
+-nodefaults \
|
|
|
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 |
+-no-acpi \
|
|
|
982648 |
+-boot strict=on \
|
|
|
982648 |
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
|
|
982648 |
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
|
|
982648 |
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
|
|
982648 |
+-chardev socket,id=charserial0,path=/tmp/serial.sock \
|
|
|
982648 |
+-device isa-serial,chardev=charserial0,id=serial0 \
|
|
|
982648 |
+-chardev socket,id=charserial1,fd=1729,server,nowait \
|
|
|
982648 |
+-device isa-serial,chardev=charserial1,id=serial1 \
|
|
|
982648 |
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
|
|
|
982648 |
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
|
|
982648 |
+resourcecontrol=deny \
|
|
|
982648 |
+-msg timestamp=on
|
|
|
982648 |
diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.xml b/tests/qemuxml2argvdata/serial-unix-chardev.xml
|
|
|
982648 |
index 04f83779ce..af513d6445 100644
|
|
|
982648 |
--- a/tests/qemuxml2argvdata/serial-unix-chardev.xml
|
|
|
982648 |
+++ b/tests/qemuxml2argvdata/serial-unix-chardev.xml
|
|
|
982648 |
@@ -25,6 +25,10 @@
|
|
|
982648 |
<source mode='connect' path='/tmp/serial.sock'/>
|
|
|
982648 |
<target port='0'/>
|
|
|
982648 |
</serial>
|
|
|
982648 |
+ <serial type='unix'>
|
|
|
982648 |
+ <source mode='bind' path='/tmp/serial-server.sock'/>
|
|
|
982648 |
+ <target port='1'/>
|
|
|
982648 |
+ </serial>
|
|
|
982648 |
<console type='unix'>
|
|
|
982648 |
<source mode='connect' path='/tmp/serial.sock'/>
|
|
|
982648 |
<target port='0'/>
|
|
|
982648 |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
982648 |
index 2d52f352b0..3be5af03aa 100644
|
|
|
982648 |
--- a/tests/qemuxml2argvtest.c
|
|
|
982648 |
+++ b/tests/qemuxml2argvtest.c
|
|
|
982648 |
@@ -1335,6 +1335,7 @@ mymain(void)
|
|
|
982648 |
QEMU_CAPS_CHARDEV_FILE_APPEND);
|
|
|
982648 |
DO_TEST("serial-unix-chardev",
|
|
|
982648 |
QEMU_CAPS_DEVICE_ISA_SERIAL);
|
|
|
982648 |
+ DO_TEST_CAPS_LATEST("serial-unix-chardev");
|
|
|
982648 |
DO_TEST("serial-tcp-chardev",
|
|
|
982648 |
QEMU_CAPS_DEVICE_ISA_SERIAL);
|
|
|
982648 |
DO_TEST("serial-udp-chardev",
|
|
|
982648 |
--
|
|
|
982648 |
2.18.0
|
|
|
982648 |
|