From nobody Mon Apr 29 01:14:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 209.132.183.28 is neither permitted nor denied by domain of redhat.com) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 209.132.183.28 is neither permitted nor denied by domain of redhat.com) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1504104620750240.7307443126989; Wed, 30 Aug 2017 07:50:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABCD77EA94; Wed, 30 Aug 2017 14:50:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C4E79174C; Wed, 30 Aug 2017 14:50:17 +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 D21511800C8A; Wed, 30 Aug 2017 14:50:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7UEnUZS011587 for ; Wed, 30 Aug 2017 10:49:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 24EAA9815F; Wed, 30 Aug 2017 14:49:30 +0000 (UTC) Received: from antique-laptop.brq.redhat.com (unknown [10.34.246.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89E4F97BAA for ; Wed, 30 Aug 2017 14:49:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ABCD77EA94 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Wed, 30 Aug 2017 16:49:25 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: set bind mode for chardev while parsing XML 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 30 Aug 2017 14:50:18 +0000 (UTC) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Currently while parsing domain XML we clear the UNIX=C2=A0path if it matches one of the auto-generated paths by libvirt. After that when the guest is started new path is generated but the mode is also changed to "bind". In the real-world use-case the mode should not change, it only happens if a user provides a mode=3D'connect' and path that matches one of the auto-generated path or not provides a path at all. Before *reconnect* feature was introduced there was no issue, but with the new feature we need to make sure that it's used only with "connect" mode, therefore we need to move the mode change into parsing in order to have a proper error reported by validation code. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 8 ++++++++ src/qemu/qemu_domain.c | 6 +++--- ...muxml2argv-chardev-reconnect-generated-path.xml | 23 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 +++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-g= enerated-path.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f7574d77b6..9fdd0f90fc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4421,6 +4421,14 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, =20 chr->target.port =3D maxport + 1; } + + /* For UNIX chardev if no path is provided we generate one. + * This also implies that the mode is 'bind'. */ + if (chr->source && + chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && + !chr->source->data.nix.path) { + chr->source->data.nix.listen =3D true; + } } =20 /* set default path for virtio-rng "random" backend to /dev/random */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bf57f94a50..ecad68d3bb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3489,8 +3489,10 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr c= hr, =20 regexp =3D virBufferContentAndReset(&buf); =20 - if (virStringMatch(chr->source->data.nix.path, regexp)) + if (virStringMatch(chr->source->data.nix.path, regexp)) { VIR_FREE(chr->source->data.nix.path); + chr->source->data.nix.listen =3D true; + } =20 ret =3D 0; cleanup: @@ -7441,8 +7443,6 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel, return -1; } =20 - channel->source->data.nix.listen =3D true; - return 0; } =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generate= d-path.xml b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generate= d-path.xml new file mode 100644 index 0000000000..3cb67ecdcc --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generated-path.= xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 1 + + hvm + + + + /usr/bin/qemu-system-i686 + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0c0bd16f94..18f06e5aa5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1351,6 +1351,9 @@ mymain(void) DO_TEST_PARSE_ERROR("chardev-reconnect-invalid-timeout", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV_RECONNECT); + DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_CHARDEV_RECONNECT); =20 DO_TEST("usb-controller", QEMU_CAPS_NODEFCONFIG); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list