From 2bb15d3f041ec2506012aa701547334af429b915 Mon Sep 17 00:00:00 2001 Message-Id: <2bb15d3f041ec2506012aa701547334af429b915@dist-git> From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 16 May 2017 10:44:54 +0200 Subject: [PATCH] conf: add to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new attribute to control interrupt remapping. https://bugzilla.redhat.com/show_bug.cgi?id=1427005 (cherry picked from commit 2020e2c6f2656ca1aa9032859ccde76185c37c39) Signed-off-by: Ján Tomko Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 24 +++++++++++++- docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 38 +++++++++++++++++++--- src/conf/domain_conf.h | 1 + .../qemuxml2argv-intel-iommu-ioapic.xml | 4 ++- 5 files changed, 70 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 869c1f73e..41b8bfb50 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7393,7 +7393,9 @@ qemu-kvm -net nic,model=? /dev/null
 ...
 <devices>
-  <iommu model='intel'/>
+  <iommu model='intel'>
+    <driver intremap='on'/>
+  </iommu>
 </devices>
 ...
 
@@ -7404,6 +7406,26 @@ qemu-kvm -net nic,model=? /dev/null Currently only the intel model is supported.

+
driver
+
+

+ The driver subelement can be used to configure + additional options: +

+
+
intremap
+
+

+ The intremap attribute with possible values + on and off can be used to + turn on interrupt remapping, a part of the VT-d functionality. + Currently this requires split I/O APIC + (<ioapic driver='qemu'/>). + Since 3.4.0 (QEMU/KVM only) +

+
+
+

Security label

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c72ba7e97..a400d961b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3893,6 +3893,15 @@ intel + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d5c4f6ddd..45473f65b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14132,12 +14132,16 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, static virDomainIOMMUDefPtr -virDomainIOMMUDefParseXML(xmlNodePtr node) +virDomainIOMMUDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt) { virDomainIOMMUDefPtr iommu = NULL, ret = NULL; + xmlNodePtr save = ctxt->node; char *tmp = NULL; int val; + ctxt->node = node; + if (VIR_ALLOC(iommu) < 0) goto cleanup; @@ -14154,10 +14158,20 @@ virDomainIOMMUDefParseXML(xmlNodePtr node) iommu->model = val; + VIR_FREE(tmp); + if ((tmp = virXPathString("string(./driver/@intremap)", ctxt))) { + if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp); + goto cleanup; + } + iommu->intremap = val; + } + ret = iommu; iommu = NULL; cleanup: + ctxt->node = save; VIR_FREE(iommu); VIR_FREE(tmp); return ret; @@ -14310,7 +14324,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_IOMMU: - if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node))) + if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt))) goto error; break; case VIR_DOMAIN_DEVICE_NONE: @@ -18440,7 +18454,7 @@ virDomainDefParseXML(xmlDocPtr xml, } if (n > 0) { - if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0]))) + if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0], ctxt))) goto error; } VIR_FREE(nodes); @@ -24096,8 +24110,24 @@ static void virDomainIOMMUDefFormat(virBufferPtr buf, const virDomainIOMMUDef *iommu) { - virBufferAsprintf(buf, "\n", + virBuffer childBuf = VIR_BUFFER_INITIALIZER; + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + + if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&childBuf, "\n", + virTristateSwitchTypeToString(iommu->intremap)); + } + + virBufferAsprintf(buf, "model)); + if (virBufferUse(&childBuf)) { + virBufferAddLit(buf, ">\n"); + virBufferAddBuffer(buf, &childBuf); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4cb37b1fc..8eb422a57 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2209,6 +2209,7 @@ typedef enum { struct _virDomainIOMMUDef { virDomainIOMMUModel model; + virTristateSwitch intremap; }; /* * Guest VM main configuration diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml index 284d63a30..bfe714ad8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml @@ -24,6 +24,8 @@ - + + + -- 2.13.0