[libvirt] [PATCHv2 6/6] qemu: format caching-mode on iommu command line

John Ferlan jferlan at redhat.com
Mon Apr 24 21:57:18 UTC 2017



On 04/20/2017 08:19 AM, Ján Tomko wrote:
> Format the caching-mode option for the intel-iommu device,
> based on its <driver caching> attribute value.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1427005
> ---
>  src/qemu/qemu_capabilities.c                          |  2 ++
>  src/qemu/qemu_capabilities.h                          |  1 +
>  src/qemu/qemu_command.c                               | 11 +++++++++++
>  tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml      |  1 +
>  .../qemuxml2argv-intel-iommu-caching.args             | 19 +++++++++++++++++++
>  tests/qemuxml2argvtest.c                              |  5 +++++
>  6 files changed, 39 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.args
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 0c7d7b1..88ea306 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -366,6 +366,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                "query-named-block-nodes",
>                "kernel-irqchip",
>                "intel-iommu-intremap",

This is the 255th capability so it'll need separation like every other
5th element with a comment after the ",  /* 255 */

> +              "intel-iommu-caching",
>      );
>  
>  
> @@ -1718,6 +1719,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
>  
>  static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
>      { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
> +    { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING },
>  };
>  
>  /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 4d19691..2409377 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -403,6 +403,7 @@ typedef enum {
>      QEMU_CAPS_QUERY_NAMED_BLOCK_NODES, /* qmp query-named-block-nodes */
>      QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
>      QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */

Likewise,

/* 255 */

Needs to be added.

> +    QEMU_CAPS_INTEL_IOMMU_CACHING, /* intel-iommu.caching-mode */
>  
>      QEMU_CAPS_LAST /* this must always be the last item */
>  } virQEMUCapsFlags;
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 1f97bd0..55800c7 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -6690,6 +6690,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
>                               "with this QEMU binary"));
>              return -1;
>          }
> +        if (iommu->caching != VIR_TRISTATE_SWITCH_ABSENT &&
> +            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_CACHING))  {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("iommu: caching mode is not supported "
> +                             "with this QEMU binary"));
> +            return -1;
> +        }
>          break;
>      case VIR_DOMAIN_IOMMU_MODEL_LAST:
>          break;
> @@ -6719,6 +6726,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
>              virBufferAsprintf(&opts, ",intremap=%s",
>                                virTristateSwitchTypeToString(iommu->intremap));
>          }
> +        if (iommu->caching != VIR_TRISTATE_SWITCH_ABSENT) {
> +            virBufferAsprintf(&opts, ",caching-mode=%s",
> +                              virTristateSwitchTypeToString(iommu->caching));
> +        }
>      case VIR_DOMAIN_IOMMU_MODEL_LAST:
>          break;
>      }
> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
> index 799c52a..0193492 100644
> --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
> +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
> @@ -209,6 +209,7 @@
>    <flag name='query-named-block-nodes'/>
>    <flag name='kernel-irqchip'/>
>    <flag name='intel-iommu-intremap'/>
> +  <flag name='intel-iommu-caching'/>
>    <version>2008090</version>
>    <kvmVersion>0</kvmVersion>
>    <package> (v2.9.0-rc0-142-g940a8ce)</package>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.args
> new file mode 100644
> index 0000000..dee63f4
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching.args
> @@ -0,0 +1,19 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu-system-x86_64 \
> +-name QEMUGuest1 \
> +-S \
> +-machine q35,accel=tcg \
> +-m 214 \
> +-smp 1,sockets=1,cores=1,threads=1 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefaults \
> +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
> +-no-acpi \
> +-boot c \
> +-device intel-iommu,intremap=on,caching-mode=on

Hmm.... so this proves that kernel-irqchip=split (or =on) isn't required
then?

It's just not clear, so I'm wondering.

Could be adjustments to the .args. based on patch5, but I think they're
obvious...

ACK with at least the comments added like other capabilities.

John

> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 29cd8b5..9950f7f 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -2497,6 +2497,11 @@ mymain(void)
>              QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
>              QEMU_CAPS_INTEL_IOMMU_INTREMAP,
>              QEMU_CAPS_DEVICE_INTEL_IOMMU);
> +    DO_TEST("intel-iommu-caching",
> +            QEMU_CAPS_MACHINE_OPT,
> +            QEMU_CAPS_DEVICE_INTEL_IOMMU,
> +            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
> +            QEMU_CAPS_INTEL_IOMMU_CACHING);
>  
>      DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
>  
> 




More information about the libvir-list mailing list