[libvirt] [PATCH 2/9] qemu: format kernel_irqchip on the command line

John Ferlan jferlan at redhat.com
Tue Mar 28 18:52:22 UTC 2017



On 03/23/2017 11:26 AM, Ján Tomko wrote:
> Add kernel_irqchip=off/split/on to the QEMU command line
> and a capability that looks for it in query-command-line-options
> output.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1427005
> ---
>  src/libvirt_private.syms                              |  1 +
>  src/qemu/qemu_capabilities.c                          |  2 ++
>  src/qemu/qemu_capabilities.h                          |  1 +
>  src/qemu/qemu_command.c                               | 11 +++++++++++
>  tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml      |  1 +
>  .../qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml |  1 +
>  .../qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml |  1 +
>  tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml     |  1 +
>  tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml       |  1 +
>  tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml       |  1 +
>  tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml      |  1 +
>  tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml      |  1 +
>  .../qemuxml2argv-intel-iommu-irqchip.args             | 19 +++++++++++++++++++
>  tests/qemuxml2argvtest.c                              |  4 ++++
>  21 files changed, 53 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
> 

You'll have merge conflicts here to resolve - something I'm sure you
already know.

> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index a1c7624..d14b81a 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -375,6 +375,7 @@ virDomainIOThreadIDAdd;
>  virDomainIOThreadIDDefFree;
>  virDomainIOThreadIDDel;
>  virDomainIOThreadIDFind;
> +virDomainIRQChipTypeToString;
>  virDomainKeyWrapCipherNameTypeFromString;
>  virDomainKeyWrapCipherNameTypeToString;
>  virDomainLeaseDefFree;
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 60ed31e..05d0a91 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -363,6 +363,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                "pcie-root-port",
>  
>                "query-cpu-definitions", /* 250 */
> +              "kernel-irqchip",
>      );
>  
>  
> @@ -2986,6 +2987,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
>      { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
>      { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
>      { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
> +    { "machine", "kernel_irqchip", QEMU_CAPS_MACHINE_KERNEL_IRQCHIP },
>  };
>  
>  static int
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 55777f9..b9efab8 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -399,6 +399,7 @@ typedef enum {
>  
>      /* 250 */
>      QEMU_CAPS_QUERY_CPU_DEFINITIONS, /* qmp query-cpu-definitions */
> +    QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
>  
>      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 2045c2e..58af585 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7316,6 +7316,17 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
>              }
>          }
>  
> +        if (def->irqchip) {

There's a relationship between irqchip setting and the features tristate
that I think should be used here to remove the need for checking
def->irqchip (and keeping a default/undefined value - from patch1).

I think the GIC example a few lines above provides an example.

Additionally does this code need to check if QEMU_CAPS_MACHINE_IOMMU was
not set or preferably that QEMU_CAPS_DEVICE_INTEL_IOMMU is set in order
to ensure the -device intel-iommu will be present?

It's my assumption from reading patch1 html.in and the reading the
comments in virQEMUCapsInitQMPMonitor regarding iommu that having
",iommu=on" may not work.  It gets even more confusing in subsequent
patches for intremap (support starting w/ qemu 2.4) and caching (support
starting with qemu 2.9).

Whether you drop a comment here or the commit message regarding what's
supported could help someone in the future trying to figure this out.


> +            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                               _("kernel-irqchip option is not supported by this "
> +                                 "QEMU binary"));
> +                goto cleanup;
> +            }
> +            virBufferAsprintf(&buf, ",kernel_irqchip=%s",
> +                              virDomainIRQChipTypeToString(def->irqchip));
> +        }
> +
>          virCommandAddArgBuffer(cmd, &buf);
>      }
>  

[...]

> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
> new file mode 100644
> index 0000000..ebf9c3e
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
> @@ -0,0 +1,19 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu \
> +-name QEMUGuest1 \
> +-S \
> +-machine q35,accel=tcg,kernel_irqchip=split \

If we can support with ",iommu=on", then we should probably have a
second test for that which uses QEMU_CAPS_MACHINE_IOMMU

Conditional ACK based on the fallout of the commandline building

John

> +-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
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 64e14af..11f6130 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -2475,6 +2475,10 @@ mymain(void)
>      DO_TEST("intel-iommu-machine",
>              QEMU_CAPS_MACHINE_OPT,
>              QEMU_CAPS_MACHINE_IOMMU);
> +    DO_TEST("intel-iommu-irqchip",
> +            QEMU_CAPS_MACHINE_OPT,
> +            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
> +            QEMU_CAPS_DEVICE_INTEL_IOMMU);
>  
>      DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
>  
> 




More information about the libvir-list mailing list