From nobody Thu May 15 09:20:52 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 1511869735792960.5547336005659; Tue, 28 Nov 2017 03:48:55 -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 C26E5883C9; Tue, 28 Nov 2017 11:48:54 +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 83F5F5D973; Tue, 28 Nov 2017 11:48:53 +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 42B8E1802121; Tue, 28 Nov 2017 11:48:53 +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 vASBmmuK008758 for ; Tue, 28 Nov 2017 06:48:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2919D60176; Tue, 28 Nov 2017 11:48:48 +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 39CE960462 for ; Tue, 28 Nov 2017 11:48:46 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 28 Nov 2017 12:47:56 +0100 Message-Id: <20171128114813.28509-14-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 13/30] conf: Parse and format virDomainChrSerialTargetModel 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.26]); Tue, 28 Nov 2017 11:48:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This information will be used to select, and store in the guest configuration in order to guarantee ABI stability, the concrete (hypervisor-specific) model for serial devices. Signed-off-by: Andrea Bolognani Reviewed-by: Pavel Hrdina --- docs/formatdomain.html.in | 16 ++++++++-- docs/schemas/domaincommon.rng | 15 +++++++++ src/conf/domain_conf.c | 72 +++++++++++++++++++++++++++++++++++++++= +++- src/conf/domain_conf.h | 12 ++++++++ 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 84cfe35a9..0a7b0e20e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6531,7 +6531,9 @@ qemu-kvm -net nic,model=3D? /dev/null <devices> <!-- USB serial port --> <serial type=3D'pty'> - <target type=3D'usb-serial' port=3D'0'/> + <target type=3D'usb-serial' port=3D'0'> + <model name=3D'usb-serial'/> + </target> <address type=3D'usb' bus=3D'0' port=3D'1'/> </serial> </devices> @@ -6547,6 +6549,16 @@ qemu-kvm -net nic,model=3D? /dev/null is available).

=20 +

+ Since 3.10.0, the target + element can have an optional model subelement; + valid values for its name attribute are: + isa-serial (usable with the isa-serial tar= get + type); usb-serial (usable with the usb-serial + target type); pci-serial + (usable with the pci-serial target type). +

+

If any of the attributes is not specified by the user, libvirt will choose a value suitable for most users. @@ -6573,7 +6585,7 @@ qemu-kvm -net nic,model=3D? /dev/null <!-- Serial console --> <console type=3D'pty'> <source path=3D'/dev/pts/2'/> - <target type=3D'serial' port=3D'0'/> + <target type=3D'serial' port=3D'0'/> </console> </devices> ... diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f1808065b..fbba092d1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3589,6 +3589,18 @@ =20 + + + + + isa-serial + usb-serial + pci-serial + + + + + @@ -3603,6 +3615,9 @@ + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 42e7596ac..5df5f3aae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -472,6 +472,14 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget, "sclp", "sclplm") =20 +VIR_ENUM_IMPL(virDomainChrSerialTargetModel, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST, + "none", + "isa-serial", + "usb-serial", + "pci-serial", +); + VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "parallel", "serial", @@ -11538,14 +11546,42 @@ virDomainChrTargetTypeFromString(int devtype, return ret; } =20 +static int +virDomainChrTargetModelFromString(int devtype, + const char *targetModel) +{ + int ret =3D -1; + + if (!targetModel) + return 0; + + switch ((virDomainChrDeviceType) devtype) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + ret =3D virDomainChrSerialTargetModelTypeFromString(targetModel); + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: + /* Target model not supported yet */ + ret =3D 0; + break; + } + + return ret; +} + static int virDomainChrDefParseTargetXML(virDomainChrDefPtr def, xmlNodePtr cur, unsigned int flags) { int ret =3D -1; + xmlNodePtr child; unsigned int port; char *targetType =3D virXMLPropString(cur, "type"); + char *targetModel =3D NULL; char *addrStr =3D NULL; char *portStr =3D NULL; char *stateStr =3D NULL; @@ -11559,6 +11595,24 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr d= ef, goto error; } =20 + child =3D cur->children; + while (child !=3D NULL) { + if (child->type =3D=3D XML_ELEMENT_NODE && + virXMLNodeNameEqual(child, "model")) { + targetModel =3D virXMLPropString(child, "name"); + } + child =3D child->next; + } + + if ((def->targetModel =3D + virDomainChrTargetModelFromString(def->deviceType, + targetModel)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown target model '%s' specified for characte= r device"), + targetModel); + goto error; + } + switch (def->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: switch (def->targetType) { @@ -11647,6 +11701,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, ret =3D 0; error: VIR_FREE(targetType); + VIR_FREE(targetModel); VIR_FREE(addrStr); VIR_FREE(portStr); VIR_FREE(stateStr); @@ -24028,8 +24083,23 @@ virDomainChrTargetDefFormat(virBufferPtr buf, } =20 virBufferAsprintf(buf, - "port=3D'%d'/>\n", + "port=3D'%d'", def->target.port); + + if (def->targetModel !=3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE)= { + virBufferAddLit(buf, ">\n"); + + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, + "\n", + virDomainChrSerialTargetModelTypeToString(de= f->targetModel)); + virBufferAdjustIndent(buf, -2); + + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } + break; =20 case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ac6c4a0ed..7895dea55 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1108,6 +1108,17 @@ typedef enum { VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST } virDomainChrConsoleTargetType; =20 +typedef enum { + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE =3D 0, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, + + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST +} virDomainChrSerialTargetModel; + +VIR_ENUM_DECL(virDomainChrSerialTargetModel); + typedef enum { VIR_DOMAIN_CHR_TYPE_NULL, VIR_DOMAIN_CHR_TYPE_VC, @@ -1206,6 +1217,7 @@ struct _virDomainChrDef { int targetType; /* enum virDomainChrConsoleTargetType || enum virDomainChrChannelTargetType || enum virDomainChrSerialTargetType according to devi= ceType */ + int targetModel; /* enum virDomainChrSerialTargetModel */ =20 union { int port; /* parallel, serial, console */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list