On Wed, Apr 26, 2017 at 10:29:06AM +0200, Ján Tomko wrote: > Add a new attribute to control the caching mode. I don't know the detailed changes below, but... I feel like using the full term "caching-mode" might be slightly better, since "caching" is a too general name used everywhere, and that might mislead people. Yes I think even "caching-mode" is misleading, but it just seems better, and that's exactly the name that Intel defined in the spec. Anyway, please feel free to ignore this comment though! (In all cases, I blame Intel for the naming :-) Thanks, > > https://bugzilla.redhat.com/show_bug.cgi?id=1427005 > --- > 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.xml | 50 ++++++++++++++++++++++ > .../qemuxml2xmlout-intel-iommu-caching.xml | 1 + > tests/qemuxml2xmltest.c | 1 + > 7 files changed, 88 insertions(+), 3 deletions(-) > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml > create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml > > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in > index e1a4625..266b16e 100644 > --- a/docs/formatdomain.html.in > +++ b/docs/formatdomain.html.in > @@ -7391,6 +7391,15 @@ qemu-kvm -net nic,model=? /dev/null > (QEMU only) > </p> > </dd> > + <dt><code>caching</code></dt> > + <dd> > + <p> > + The <code>caching</code> attribute with possible values > + <code>on</code> and <code>off</code> can be used to > + turn on the caching mode. <span class="since">Since 3.3.0</span> > + (QEMU only) > + </p> > + </dd> > </dl> > </dd> > </dl> > diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng > index cc10209..74cd863 100644 > --- a/docs/schemas/domaincommon.rng > +++ b/docs/schemas/domaincommon.rng > @@ -3899,6 +3899,11 @@ > <ref name="virOnOff"/> > </attribute> > </optional> > + <optional> > + <attribute name="caching"> > + <ref name="virOnOff"/> > + </attribute> > + </optional> > </element> > </optional> > </element> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 650d206..6c696c8 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -14171,6 +14171,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, > iommu->intremap = val; > } > > + VIR_FREE(tmp); > + if ((tmp = virXPathString("string(./driver/@caching)", ctxt))) { > + if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { > + virReportError(VIR_ERR_XML_ERROR, _("unknown caching value: %s"), tmp); > + goto cleanup; > + } > + iommu->caching = val; > + } > + > ret = iommu; > iommu = NULL; > > @@ -24118,9 +24127,18 @@ virDomainIOMMUDefFormat(virBufferPtr buf, > > virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); > > - if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { > - virBufferAsprintf(&childBuf, "<driver intremap='%s'/>\n", > - virTristateSwitchTypeToString(iommu->intremap)); > + if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT || > + iommu->caching != VIR_TRISTATE_SWITCH_ABSENT) { > + virBufferAddLit(&childBuf, "<driver"); > + if (iommu->intremap) { > + virBufferAsprintf(&childBuf, " intremap='%s'", > + virTristateSwitchTypeToString(iommu->intremap)); > + } > + if (iommu->caching != VIR_TRISTATE_SWITCH_ABSENT) { > + virBufferAsprintf(&childBuf, " caching='%s'", > + virTristateSwitchTypeToString(iommu->caching)); > + } > + virBufferAddLit(&childBuf, "/>\n"); > } > > virBufferAsprintf(buf, "<iommu model='%s'", > diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h > index 61f18cf..97c9356 100644 > --- a/src/conf/domain_conf.h > +++ b/src/conf/domain_conf.h > @@ -2214,6 +2214,7 @@ typedef enum { > struct _virDomainIOMMUDef { > virDomainIOMMUModel model; > virTristateSwitch intremap; > + virTristateSwitch caching; > }; > /* > * Guest VM main configuration > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml > new file mode 100644 > index 0000000..8261d5a > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml > @@ -0,0 +1,50 @@ > +<domain type='qemu'> > + <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> > + <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='pci' index='1' model='dmi-to-pci-bridge'> > + <model name='i82801b11-bridge'/> > + <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/> > + </controller> > + <controller type='pci' index='2' model='pci-bridge'> > + <model name='pci-bridge'/> > + <target chassisNr='2'/> > + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> > + </controller> > + <controller type='pci' index='3' model='pcie-root-port'> > + <model name='ioh3420'/> > + <target chassis='3' port='0x10'/> > + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> > + </controller> > + <controller type='sata' index='0'> > + <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> > + </controller> > + <controller type='usb' index='0' model='ich9-ehci1'> > + <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x7'/> > + </controller> > + <interface type='user'> > + <mac address='52:54:00:ab:0c:5c'/> > + <model type='rtl8139'/> > + <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> > + </interface> > + <input type='mouse' bus='ps2'/> > + <input type='keyboard' bus='ps2'/> > + <memballoon model='none'/> > + <iommu model='intel'> > + <driver intremap='on' caching='on'/> > + </iommu> > + </devices> > +</domain> > diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml > new file mode 120000 > index 0000000..6935d93 > --- /dev/null > +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml > @@ -0,0 +1 @@ > +../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml > \ No newline at end of file > diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c > index 40425f5..848da4f 100644 > --- a/tests/qemuxml2xmltest.c > +++ b/tests/qemuxml2xmltest.c > @@ -1123,6 +1123,7 @@ mymain(void) > QEMU_CAPS_MACHINE_OPT, > QEMU_CAPS_MACHINE_IOMMU); > DO_TEST("intel-iommu-irqchip", NONE); > + DO_TEST("intel-iommu-caching", NONE); > > DO_TEST("cpu-check-none", NONE); > DO_TEST("cpu-check-partial", NONE); > -- > 2.10.2 > -- Peter Xu -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list