From nobody Fri Mar 29 05:33:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530871394417227.68272761743094; Fri, 6 Jul 2018 03:03:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 959FE30832F3; Fri, 6 Jul 2018 10:03:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3DD62015E40; Fri, 6 Jul 2018 10:03:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 84FE44A460; Fri, 6 Jul 2018 10:03:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w66A365m014122 for ; Fri, 6 Jul 2018 06:03:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A5892026DE8; Fri, 6 Jul 2018 10:03:06 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EF5C2026D68; Fri, 6 Jul 2018 10:03:04 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 6 Jul 2018 11:03:00 +0100 Message-Id: <20180706100300.30777-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: fix UNIX socket chardevs operating in client mode X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 06 Jul 2018 10:03:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9 --- 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-lates= t.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; =20 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)de= f) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.args b/tests/qemuxm= l2argvdata/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=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ -chardev socket,id=3Dcharserial0,path=3D/tmp/serial.sock \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0 \ +-chardev socket,id=3Dcharserial1,path=3D/tmp/serial-server.sock,server,now= ait \ +-device isa-serial,chardev=3Dcharserial1,id=3Dserial1 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 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=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-chardev socket,id=3Dcharserial0,path=3D/tmp/serial.sock \ +-device isa-serial,chardev=3Dcharserial0,id=3Dserial0 \ +-chardev socket,id=3Dcharserial1,fd=3D1729,server,nowait \ +-device isa-serial,chardev=3Dcharserial1,id=3Dserial1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.xml b/tests/qemuxml= 2argvdata/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", --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list