commit d12781b47eb0c9f3a498d88b632c327aa08aaf8a
Author: Ján Tomko
Date: Fri Mar 17 08:27:49 2017 +0100
conf: add caching_mode attribute to iommu device
Add a new attribute to control the caching mode.
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
Index: libvirt-3.3.0/docs/formatdomain.html.in
===================================================================
--- libvirt-3.3.0.orig/docs/formatdomain.html.in
+++ libvirt-3.3.0/docs/formatdomain.html.in
@@ -7427,6 +7427,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)
+
+
Index: libvirt-3.3.0/docs/schemas/domaincommon.rng
===================================================================
--- libvirt-3.3.0.orig/docs/schemas/domaincommon.rng
+++ libvirt-3.3.0/docs/schemas/domaincommon.rng
@@ -3954,6 +3954,11 @@
+
+
+
+
+
Index: libvirt-3.3.0/src/conf/domain_conf.c
===================================================================
--- libvirt-3.3.0.orig/src/conf/domain_conf.c
+++ libvirt-3.3.0/src/conf/domain_conf.c
@@ -14176,6 +14176,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr nod
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;
@@ -24143,9 +24152,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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: libvirt-3.3.0/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
===================================================================
--- /dev/null
+++ libvirt-3.3.0/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml
@@ -0,0 +1,50 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: libvirt-3.3.0/tests/qemuxml2xmltest.c
===================================================================
--- libvirt-3.3.0.orig/tests/qemuxml2xmltest.c
+++ libvirt-3.3.0/tests/qemuxml2xmltest.c
@@ -1123,6 +1123,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);