Re: [PATCH 8/9] conf: add caching attribute to iommu device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 03/23/2017 11:26 AM, Ján Tomko wrote:
> Add a new attribute to control the caching mode.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1427005
> ---
>  docs/formatdomain.html.in                          |  9 +++++++
>  docs/schemas/domaincommon.rng                      |  5 ++++
>  src/conf/domain_conf.c                             | 23 +++++++++++++++---
>  src/conf/domain_conf.h                             |  1 +
>  .../qemuxml2argv-intel-iommu-caching.xml           | 28 ++++++++++++++++++++++
>  .../qemuxml2xmlout-intel-iommu-caching.xml         | 28 ++++++++++++++++++++++
>  tests/qemuxml2xmltest.c                            |  2 ++
>  7 files changed, 93 insertions(+), 3 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml
>  create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 6b196d4..f3c44ae 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -7314,6 +7314,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>

Similar comment/concert regarding irqchip setting as from patch4

>          </dl>
>        </dd>
>      </dl>
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 68f3680..49adf69 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -3896,6 +3896,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 da0c9f0..6bcf84e 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -13944,6 +13944,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;
>  
> @@ -23864,9 +23873,17 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
>  
>      virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
>  
> -    if (iommu->intremap) {
> -        virBufferAsprintf(&childBuf, "<driver intremap='%s'/>\n",
> -                          virTristateSwitchTypeToString(iommu->intremap));
> +    if (iommu->intremap || iommu->caching) {

Same comment regarding bool/pointer... Not that it really matters
technically, but it would seem to be a more proper comparison.

> +        virBufferAddLit(&childBuf, "<driver");
> +        if (iommu->intremap) {
> +            virBufferAsprintf(&childBuf, " intremap='%s'",
> +                              virTristateSwitchTypeToString(iommu->intremap));
> +        }
> +        if (iommu->caching) {
> +            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 ad8ae2d..af63b51 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -2204,6 +2204,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..b3ce6b4
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.xml
> @@ -0,0 +1,28 @@
> +<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</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' caching='on'/>

Does it matter if intremap is on or off?  Since this is a different
test, you could go with off or even better not present to test the logic
to add just caching would work...

> +    </iommu>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml
> new file mode 100644
> index 0000000..b3ce6b4

Similar comment from patch1 regarding this being a link.


John
> --- /dev/null
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching.xml
> @@ -0,0 +1,28 @@
> +<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</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' caching='on'/>
> +    </iommu>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index 8afd830..20add1b 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -1126,6 +1126,8 @@ mymain(void)
>              QEMU_CAPS_MACHINE_IOMMU);
>      DO_TEST("intel-iommu-irqchip",
>              QEMU_CAPS_DEVICE_INTEL_IOMMU);
> +    DO_TEST("intel-iommu-caching",
> +            QEMU_CAPS_DEVICE_INTEL_IOMMU);
>  
>      DO_TEST("cpu-check-none", NONE);
>      DO_TEST("cpu-check-partial", NONE);
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux