From 3b7b827deb9eb7f43f548aabd27c300ae24c7db3 Mon Sep 17 00:00:00 2001 Message-Id: <3b7b827deb9eb7f43f548aabd27c300ae24c7db3@dist-git> From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 16 May 2017 10:44:56 +0200 Subject: [PATCH] conf: add caching_mode attribute to iommu device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new attribute to control the caching mode. https://bugzilla.redhat.com/show_bug.cgi?id=1427005 (cherry picked from commit d12781b47eb0c9f3a498d88b632c327aa08aaf8a) Signed-off-by: Ján Tomko Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 9 ++++ docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 24 +++++++++-- src/conf/domain_conf.h | 1 + .../qemuxml2argv-intel-iommu-caching-mode.xml | 50 ++++++++++++++++++++++ .../qemuxml2xmlout-intel-iommu-caching-mode.xml | 1 + tests/qemuxml2xmltest.c | 1 + 7 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 41b8bfb50..43a75c1ee 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7424,6 +7424,15 @@ qemu-kvm -net nic,model=? /dev/null Since 3.4.0 (QEMU/KVM only)

+
caching_mode
+
+

+ The caching_mode attribute with possible values + on and off can be used to + turn on the VT-d caching mode (useful for assigned devices). + Since 3.4.0 (QEMU/KVM only) +

+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a400d961b..12ccbd4e2 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3900,6 +3900,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 45473f65b..e77b542f3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14167,6 +14167,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, iommu->intremap = val; } + VIR_FREE(tmp); + if ((tmp = virXPathString("string(./driver/@caching_mode)", ctxt))) { + if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp); + goto cleanup; + } + iommu->caching_mode = val; + } + ret = iommu; iommu = NULL; @@ -24114,9 +24123,18 @@ virDomainIOMMUDefFormat(virBufferPtr buf, virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); - if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(&childBuf, "\n", - virTristateSwitchTypeToString(iommu->intremap)); + if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT || + iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAddLit(&childBuf, "intremap != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&childBuf, " intremap='%s'", + virTristateSwitchTypeToString(iommu->intremap)); + } + if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&childBuf, " caching_mode='%s'", + virTristateSwitchTypeToString(iommu->caching_mode)); + } + virBufferAddLit(&childBuf, "/>\n"); } virBufferAsprintf(buf, " + 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-caching-mode.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml new file mode 120000 index 000000000..d971a35dc --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 0482ad9cb..e1938421a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1129,6 +1129,7 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_IOMMU); DO_TEST("intel-iommu-ioapic", NONE); + DO_TEST("intel-iommu-caching-mode", NONE); DO_TEST("cpu-check-none", NONE); DO_TEST("cpu-check-partial", NONE); -- 2.13.0