From nobody Thu May 15 09:04:55 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1511869724729695.8955532063569; Tue, 28 Nov 2017 03:48:44 -0800 (PST) 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 B09AC37E6E; Tue, 28 Nov 2017 11:48:43 +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 8A67B5D965; Tue, 28 Nov 2017 11:48:43 +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 51BD21800FC4; Tue, 28 Nov 2017 11:48:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vASBmPXi008639 for ; Tue, 28 Nov 2017 06:48:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 696D260176; Tue, 28 Nov 2017 11:48:25 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-77.brq.redhat.com [10.40.204.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9585E60175 for ; Tue, 28 Nov 2017 11:48:24 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 28 Nov 2017 12:47:45 +0100 Message-Id: <20171128114813.28509-3-abologna@redhat.com> In-Reply-To: <20171128114813.28509-1-abologna@redhat.com> References: <20171128114813.28509-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 02/30] qemu: Introduce qemuDomainChrDefPostParse() 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 28 Nov 2017 11:48:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Having a separate function for char device handling is better than adding even more code to qemuDomainDeviceDefPostParse(). Signed-off-by: Andrea Bolognani Reviewed-by: Pavel Hrdina Reviewed-by: Marc Hartmayer --- src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9dab6b24b..e59aedcfd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4086,6 +4086,35 @@ qemuDomainControllerDefPostParse(virDomainController= DefPtr cont, return 0; } =20 +static int +qemuDomainChrDefPostParse(virDomainChrDefPtr chr, + const virDomainDef *def, + virQEMUDriverPtr driver, + unsigned int parseFlags) +{ + /* set the default console type for S390 arches */ + if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + ARCH_IS_S390(def->os.arch)) { + chr->targetType =3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; + } + + /* clear auto generated unix socket path for inactive definitions */ + if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { + if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) + return -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; + } + } + + return 0; +} =20 static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, @@ -4146,29 +4175,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, } } =20 - /* set the default console type for S390 arches */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && - dev->data.chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOL= E && - dev->data.chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYP= E_NONE && - ARCH_IS_S390(def->os.arch)) - dev->data.chr->targetType =3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_V= IRTIO; - - /* clear auto generated unix socket path for inactive definitions */ - if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR) { - 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; - } - } - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { if (dev->data.video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { if ARCH_IS_PPC64(def->os.arch) @@ -4204,6 +4210,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, qemuDomainShmemDefPostParse(dev->data.shmem) < 0) goto cleanup; =20 + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR && + qemuDomainChrDefPostParse(dev->data.chr, def, driver, parseFlags) = < 0) { + goto cleanup; + } + ret =3D 0; =20 cleanup: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list