Add a new device_iotlb attribute to the iommu device
to control the device IOTLB support for intel-iommu.
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
---
docs/formatdomain.html.in | 9 +++++++
docs/schemas/domaincommon.rng | 5 ++++
src/conf/domain_conf.c | 15 ++++++++++-
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, 62 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 07208ee..2f1e030 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7449,6 +7449,15 @@ qemu-kvm -net nic,model=? /dev/null
<span class="since">Since 3.4.0</span> (QEMU/KVM
only)
</p>
</dd>
+ <dt><code>device_iotlb</code></dt>
+ <dd>
+ <p>
+ The <code>device_iotlb</code> attribute with possible values
+ <code>on</code> and <code>off</code> can be used
to
+ turn on the device IOTLB descriptor.
+ <span class="since">Since 3.5.0</span> (QEMU/KVM
only)
+ </p>
+ </dd>
</dl>
</dd>
</dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4d9f8d1..6c3e885 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3964,6 +3964,11 @@
<ref name="virOnOff"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="device_iotlb">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
</element>
</optional>
</element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b47a376..c83af5d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14201,6 +14201,14 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
}
iommu->caching_mode = val;
}
+ VIR_FREE(tmp);
+ if ((tmp = virXPathString("string(./driver/@device_iotlb)", ctxt))) {
+ if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR, _("unknown device_iotlb value:
%s"), tmp);
+ goto cleanup;
+ }
+ iommu->device_iotlb = val;
+ }
VIR_FREE(tmp);
if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) {
@@ -24246,7 +24254,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->device_iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAddLit(&childBuf, "<driver");
if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAsprintf(&childBuf, " intremap='%s'",
@@ -24260,6 +24269,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
virBufferAsprintf(&childBuf, " eim='%s'",
virTristateSwitchTypeToString(iommu->eim));
}
+ if (iommu->device_iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(&childBuf, " device_iotlb='%s'",
+ virTristateSwitchTypeToString(iommu->device_iotlb));
+ }
virBufferAddLit(&childBuf, "/>\n");
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 83e0672..cb570ef 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2212,6 +2212,7 @@ struct _virDomainIOMMUDef {
virTristateSwitch intremap;
virTristateSwitch caching_mode;
virTristateSwitch eim;
+ virTristateSwitch device_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 0000000..0cdf2aa
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
@@ -0,0 +1,31 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <ioapic driver='qemu'/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x1f' function='0x2'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ <iommu model='intel'>
+ <driver intremap='on' device_iotlb='on'/>
+ </iommu>
+ </devices>
+</domain>
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 0000000..3120d9f
--- /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 fff13e2..5e8cead 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1128,6 +1128,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.10.2