]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: add iotlb attribute to iommu
authorJán Tomko <jtomko@redhat.com>
Wed, 3 May 2017 15:07:55 +0000 (17:07 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Jun 2017 14:31:09 +0000 (16:31 +0200)
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 <phrdina@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml [new symlink]
tests/qemuxml2xmltest.c

index 07208eef89a88e29fd69f45722e82e8bbd19f152..fa0edd1582b48573b282dc5e03ad4f64962a67c7 100644 (file)
@@ -7449,6 +7449,16 @@ qemu-kvm -net nic,model=? /dev/null
               <span class="since">Since 3.4.0</span> (QEMU/KVM only)
             </p>
           </dd>
+          <dt><code>iotlb</code></dt>
+          <dd>
+            <p>
+              The <code>iotlb</code> attribute with possible values
+              <code>on</code> and <code>off</code> can be used to
+              turn on the IOTLB used to cache address translation
+              requests from devices.
+              <span class="since">Since 3.5.0</span> (QEMU/KVM only)
+            </p>
+          </dd>
         </dl>
       </dd>
     </dl>
index 4d9f8d1a25ab1372f025d6a75854db8f878fb61b..5c542c782a48baef1ade3c8046152c36af2765e6 100644 (file)
               <ref name="virOnOff"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="iotlb">
+              <ref name="virOnOff"/>
+            </attribute>
+          </optional>
         </element>
       </optional>
     </element>
index d4ee92eec5c9faa82e9fd03576b092db9e38f40a..625449ad23ceef953d6fd232550da86828abd457 100644 (file)
@@ -14222,6 +14222,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))) {
@@ -19950,6 +19958,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;
 }
 
@@ -24264,7 +24280,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, "<driver");
         if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
             virBufferAsprintf(&childBuf, " intremap='%s'",
@@ -24278,6 +24295,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");
     }
 
index 1231aeac6831e9aa2a04921aaee98ba0d64b1a6f..597fb22cca7546387d61a242307d307ec9bfed38 100644 (file)
@@ -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 (file)
index 0000000..3eb08ab
--- /dev/null
@@ -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' 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 (symlink)
index 0000000..3120d9f
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml
\ No newline at end of file
index 6aececb598ef6491f382b445537112bc77a08278..31c624b86a7a0f84a696c2318e770993fc82d086 100644 (file)
@@ -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);