From nobody Fri May 16 10:38:48 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.zoho.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 14961488052871016.7834332592101; Tue, 30 May 2017 05:53:25 -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 3D1CA80479; Tue, 30 May 2017 12:53:23 +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 16DAF7E39C; Tue, 30 May 2017 12:53:23 +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 C48E14A494; Tue, 30 May 2017 12:53:22 +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 v4UCrLUu013249 for ; Tue, 30 May 2017 08:53:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50D7F5C7C0; Tue, 30 May 2017 12:53:21 +0000 (UTC) Received: from icr.brq.redhat.com (dhcp129-58.brq.redhat.com [10.34.129.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id A40DD5C7A9; Tue, 30 May 2017 12:53:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D1CA80479 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3D1CA80479 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 30 May 2017 14:50:32 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: jasowang@redhat.com Subject: [libvirt] [PATCH 09/18] Add virtio-related options to interfaces 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.28]); Tue, 30 May 2017 12:53:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1283251 --- docs/formatdomain.html.in | 19 +++++++ docs/schemas/domaincommon.rng | 12 +++++ src/conf/domain_conf.c | 63 ++++++++++++++++++= ++++ src/conf/domain_conf.h | 19 +++++++ .../qemuxml2argv-virtio-options.xml | 2 + .../qemuxml2xmlout-virtio-options.xml | 2 + 6 files changed, 117 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 2f1e030..dcc2e5e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3451,6 +3451,19 @@ =20 +

Virtio-related options

+ +

+ QEMU's virtio devices have some attributes related to the virtio tra= nsport under + the driver element: + The iommu_platform attribute enables the use of emulate= d IOMMU + by the device. The attribute ats controls the Address + Translation Service support for PCIe devices. This is needed to make= use + of IOTLB support (see IOMMU device). + Possible values are on or off. + Since 3.5.0 +

+

Controllers

=20

@@ -5142,6 +5155,12 @@ qemu-kvm -net nic,model=3D? /dev/null In general you should leave this option alone, unless you are very certain you know what you are doing. +

virtio options
+
+ For virtio interfaces, + Virtio-specific options can also be + set. (Since 3.5.0) +

Offloading options for the host and guest can be configured using diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6c3e885..d7f3b02 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2686,6 +2686,7 @@ + @@ -5006,6 +5007,17 @@ =20 + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c83af5d..a83f7dc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1098,6 +1098,46 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr= xmlopt) return &xmlopt->ns; } =20 +static int +virDomainVirtioOptionsParseXML(xmlXPathContextPtr ctxt, + virDomainVirtioOptionsPtr *virtio) +{ + char *str =3D NULL; + int ret =3D -1; + int val; + virDomainVirtioOptionsPtr res; + + if (VIR_ALLOC(*virtio) < 0) + return -1; + + res =3D *virtio; + + if ((str =3D virXPathString("string(./driver/@iommu_platform)", ctxt))= ) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid iommu_platform value")); + goto cleanup; + } + res->iommu_platform =3D val; + } + VIR_FREE(str); + + if ((str =3D virXPathString("string(./driver/@ats)", ctxt))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid ats value")); + goto cleanup; + } + res->ats =3D val; + } + + ret =3D 0; + + cleanup: + VIR_FREE(str); + return ret; +} + =20 void virBlkioDeviceArrayClear(virBlkioDevicePtr devices, @@ -1945,6 +1985,7 @@ virDomainNetDefClear(virDomainNetDefPtr def) VIR_FREE(def->ifname); VIR_FREE(def->ifname_guest); VIR_FREE(def->ifname_guest_actual); + VIR_FREE(def->virtio); =20 virNetDevIPInfoClear(&def->guestIP); virNetDevIPInfoClear(&def->hostIP); @@ -5214,6 +5255,24 @@ virDomainDefValidate(virDomainDefPtr def, } =20 =20 +static void +virDomainVirtioOptionsFormat(virBufferPtr buf, + virDomainVirtioOptionsPtr virtio) +{ + if (!virtio) + return; + + if (virtio->iommu_platform !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, "iommu_platform=3D'%s' ", + virTristateSwitchTypeToString(virtio->iommu_plat= form)); + } + if (virtio->ats !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, "ats=3D'%s' ", + virTristateSwitchTypeToString(virtio->ats)); + } +} + + /* Generate a string representation of a device address * @info address Device address to stringify */ @@ -10360,6 +10419,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } =20 + if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0) + goto error; + cleanup: ctxt->node =3D oldnode; VIR_FREE(macaddr); @@ -22092,6 +22154,7 @@ virDomainVirtioNetDriverFormat(char **outstr, virBufferAsprintf(&buf, "rx_queue_size=3D'%u' ", def->driver.virtio.rx_queue_size); =20 + virDomainVirtioOptionsFormat(&buf, def->virtio); virBufferTrim(&buf, " ", -1); =20 if (virBufferCheckError(&buf) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cb570ef..68f8d0c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -155,6 +155,17 @@ typedef virDomainTPMDef *virDomainTPMDefPtr; typedef struct _virDomainIOMMUDef virDomainIOMMUDef; typedef virDomainIOMMUDef *virDomainIOMMUDefPtr; =20 +typedef struct _virDomainVirtioOptions virDomainVirtioOptions; +typedef virDomainVirtioOptions *virDomainVirtioOptionsPtr; + +typedef enum { + VIR_DOMAIN_DRIVER_COMPATIBILITY_DEFAULT, + VIR_DOMAIN_DRIVER_COMPATIBILITY_LEGACY, + VIR_DOMAIN_DRIVER_COMPATIBILITY_TRANSITIONAL, + VIR_DOMAIN_DRIVER_COMPATIBILITY_MODERN, + VIR_DOMAIN_DRIVER_COMPATIBILITY_LAST, +} virDomainDriverCompatibility; + /* Flags for the 'type' field in virDomainDeviceDef */ typedef enum { VIR_DOMAIN_DEVICE_NONE =3D 0, @@ -1039,6 +1050,7 @@ struct _virDomainNetDef { int linkstate; unsigned int mtu; virNetDevCoalescePtr coalesce; + virDomainVirtioOptionsPtr virtio; }; =20 typedef enum { @@ -2214,6 +2226,12 @@ struct _virDomainIOMMUDef { virTristateSwitch eim; virTristateSwitch device_iotlb; }; + +struct _virDomainVirtioOptions { + virTristateSwitch iommu_platform; + virTristateSwitch ats; +}; + /* * Guest VM main configuration * @@ -3174,6 +3192,7 @@ VIR_ENUM_DECL(virDomainMemorySource) VIR_ENUM_DECL(virDomainMemoryAllocation) VIR_ENUM_DECL(virDomainIOMMUModel) VIR_ENUM_DECL(virDomainShmemModel) +VIR_ENUM_DECL(virDomainDriverCompatibility) /* from libvirt.h */ VIR_ENUM_DECL(virDomainState) VIR_ENUM_DECL(virDomainNostateReason) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests= /qemuxml2argvdata/qemuxml2argv-virtio-options.xml index 9ead938..a2bbbee 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml @@ -53,11 +53,13 @@ +

+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml b/t= ests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml index 9ead938..a2bbbee 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml @@ -53,11 +53,13 @@ +
+
--=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list