From nobody Sun Apr 28 20:22:04 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 1504108429649995.6579953454473; Wed, 30 Aug 2017 08:53:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B27B285A8; Wed, 30 Aug 2017 15:53:47 +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 3162D70932; Wed, 30 Aug 2017 15:53:47 +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 D74991806107; Wed, 30 Aug 2017 15:53:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7UFrkcL021190 for ; Wed, 30 Aug 2017 11:53:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 01CE070944; Wed, 30 Aug 2017 15:53:46 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DC497093F for ; Wed, 30 Aug 2017 15:53:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5B27B285A8 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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 17:53:40 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] 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: , MIME-Version: 1.0 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 30 Aug 2017 15:53:47 +0000 (UTC) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently while parsing domain XML we clear the UNIX path 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/qemu/qemu_domain.c | 13 +++++++++--- ...muxml2argv-chardev-reconnect-generated-path.xml | 23 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 +++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-g= enerated-path.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bf57f94a50..cbee151f5d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3766,8 +3766,17 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, /* clear auto generated unix socket path for inactive definitions */ if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR) { - if (qemuDomainChrDefDropDefaultPath(dev->data.chr, driver) < 0) + virDomainChrDefPtr chr =3D dev->data.chr; + if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) goto cleanup; + + /* 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 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { @@ -7441,8 +7450,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