From 1e915e38d422df8b3cb4e049e932a5e6900735bc Mon Sep 17 00:00:00 2001 Message-Id: <1e915e38d422df8b3cb4e049e932a5e6900735bc@dist-git> From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 9 Jun 2017 12:48:56 +0200 Subject: [PATCH] conf: add iotlb attribute to iommu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new iotlb attribute to the iommu device to control the device IOTLB support for intel-iommu. https://bugzilla.redhat.com/show_bug.cgi?id=1283251 Reviewed-by: Pavel Hrdina (cherry picked from commit 27b187be3988c60cd26e08ab4bcab66bed5a3646) Signed-off-by: Ján Tomko Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 10 +++++++ docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 23 +++++++++++++++- src/conf/domain_conf.h | 1 + .../qemuxml2argv-intel-iommu-device-iotlb.xml | 31 ++++++++++++++++++++++ .../qemuxml2xmlout-intel-iommu-device-iotlb.xml | 1 + tests/qemuxml2xmltest.c | 1 + 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e886e4e17e..e8a3367bac 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7446,6 +7446,16 @@ qemu-kvm -net nic,model=? /dev/null Since 3.4.0 (QEMU/KVM only)

+
iotlb
+
+

+ The iotlb attribute with possible values + on and off can be used to + turn on the IOTLB used to cache address translation + requests from devices. + Since 3.5.0 (QEMU/KVM only) +

+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index af7824aa02..1b66362f17 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3910,6 +3910,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 275145b1ec..701a6d2136 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14196,6 +14196,14 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, } iommu->caching_mode = val; } + VIR_FREE(tmp); + if ((tmp = virXPathString("string(./driver/@iotlb)", ctxt))) { + if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp); + goto cleanup; + } + iommu->iotlb = val; + } VIR_FREE(tmp); if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) { @@ -19877,6 +19885,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, virTristateSwitchTypeToString(src->eim)); return false; } + if (src->iotlb != dst->iotlb) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device iotlb value '%s' " + "does not match source '%s'"), + virTristateSwitchTypeToString(dst->iotlb), + virTristateSwitchTypeToString(src->iotlb)); + return false; + } return true; } @@ -24212,7 +24228,8 @@ virDomainIOMMUDefFormat(virBufferPtr buf, virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT || - iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { + iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT || + iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) { virBufferAddLit(&childBuf, "intremap != VIR_TRISTATE_SWITCH_ABSENT) { virBufferAsprintf(&childBuf, " intremap='%s'", @@ -24226,6 +24243,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf, virBufferAsprintf(&childBuf, " eim='%s'", virTristateSwitchTypeToString(iommu->eim)); } + if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&childBuf, " iotlb='%s'", + virTristateSwitchTypeToString(iommu->iotlb)); + } virBufferAddLit(&childBuf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 706d106ad9..e6c20a9e1e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2213,6 +2213,7 @@ struct _virDomainIOMMUDef { virTristateSwitch intremap; virTristateSwitch caching_mode; virTristateSwitch eim; + virTristateSwitch iotlb; }; /* * Guest VM main configuration diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml new file mode 100644 index 0000000000..3eb08ab9af --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml @@ -0,0 +1,31 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + +
+ + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml new file mode 120000 index 0000000000..3120d9f677 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 6283da4096..3f7c268e43 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1131,6 +1131,7 @@ mymain(void) DO_TEST("intel-iommu-ioapic", NONE); DO_TEST("intel-iommu-caching-mode", NONE); DO_TEST("intel-iommu-eim", NONE); + DO_TEST("intel-iommu-device-iotlb", NONE); DO_TEST("cpu-check-none", NONE); DO_TEST("cpu-check-partial", NONE); -- 2.13.1