commit 6b5c6314b2f7a3b54c94a591e6b0dcd13ef1c6ce Author: Ján Tomko Date: Fri Mar 17 08:26:49 2017 +0100 qemu: format kernel_irqchip on the command line Add kernel_irqchip=split/on to the QEMU command line and a capability that looks for it in query-command-line-options output. For the 'split' option, use a version check since it cannot be reasonably probed. https://bugzilla.redhat.com/show_bug.cgi?id=1427005 Index: libvirt-3.3.0/src/qemu/qemu_capabilities.c =================================================================== --- libvirt-3.3.0.orig/src/qemu/qemu_capabilities.c +++ libvirt-3.3.0/src/qemu/qemu_capabilities.c @@ -366,6 +366,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAS "query-named-block-nodes", "cpu-cache", "qemu-xhci", + + "kernel-irqchip", /* 255 */ + "kernel-irqchip.split", ); @@ -3127,6 +3130,7 @@ static struct virQEMUCapsCommandLineProp { "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 @@ -4739,6 +4743,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr if (qemuCaps->version >= 2004050) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION); + /* no way to query if -machine kernel_irqchip supports split */ + if (qemuCaps->version >= 2006000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT); + if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0) goto cleanup; Index: libvirt-3.3.0/src/qemu/qemu_capabilities.h =================================================================== --- libvirt-3.3.0.orig/src/qemu/qemu_capabilities.h +++ libvirt-3.3.0/src/qemu/qemu_capabilities.h @@ -404,6 +404,10 @@ typedef enum { QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */ QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */ + /* 255 */ + QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */ + QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; Index: libvirt-3.3.0/src/qemu/qemu_command.c =================================================================== --- libvirt-3.3.0.orig/src/qemu/qemu_command.c +++ libvirt-3.3.0/src/qemu/qemu_command.c @@ -7422,6 +7422,31 @@ qemuBuildMachineCommandLine(virCommandPt } } + if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("I/O APIC tuning is not supported by this " + "QEMU binary")); + goto cleanup; + } + switch (def->ioapic) { + case VIR_DOMAIN_IOAPIC_QEMU: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("split I/O APIC is not supported by this " + "QEMU binary")); + goto cleanup; + } + virBufferAddLit(&buf, ",kernel_irqchip=split"); + break; + case VIR_DOMAIN_IOAPIC_KVM: + virBufferAddLit(&buf, ",kernel_irqchip=on"); + break; + case VIR_DOMAIN_IOAPIC_LAST: + break; + } + } + virCommandAddArgBuffer(cmd, &buf); } Index: libvirt-3.3.0/src/qemu/qemu_domain.c =================================================================== --- libvirt-3.3.0.orig/src/qemu/qemu_domain.c +++ libvirt-3.3.0/src/qemu/qemu_domain.c @@ -2807,6 +2807,22 @@ qemuDomainDefCPUPostParse(virDomainDefPt static int +qemuDomainDefVerifyFeatures(const virDomainDef *def) +{ + if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON && + !ARCH_IS_X86(def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("I/O APIC tuning is not supported " + "for '%s' architecture"), + virArchToString(def->os.arch)); + return -1; + } + + return 0; +} + + +static int qemuDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, @@ -2861,6 +2877,9 @@ qemuDomainDefPostParse(virDomainDefPtr d qemuDomainDefEnableDefaultFeatures(def, qemuCaps); + if (qemuDomainDefVerifyFeatures(def) < 0) + goto cleanup; + if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0) goto cleanup; Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml @@ -140,6 +140,7 @@ + 1005003 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml @@ -145,6 +145,7 @@ + 1006000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml @@ -147,6 +147,7 @@ + 1007000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml @@ -163,6 +163,7 @@ + 2001001 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -185,6 +185,7 @@ + 2004000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -191,6 +191,7 @@ + 2005000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -168,6 +168,8 @@ + + 2006000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -168,6 +168,8 @@ + + 2006000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml @@ -162,6 +162,8 @@ + + 2006000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -200,6 +200,8 @@ + + 2006000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -130,6 +130,8 @@ + + 2007000 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -202,6 +202,8 @@ + + 2007000 0 (v2.7.0) Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -132,6 +132,8 @@ + + 2007093 0 Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -203,6 +203,8 @@ + + 2008000 0 (v2.8.0) Index: libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml =================================================================== --- libvirt-3.3.0.orig/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ libvirt-3.3.0/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -210,6 +210,8 @@ + + 2009000 0 (v2.9.0) Index: libvirt-3.3.0/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.args =================================================================== --- /dev/null +++ libvirt-3.3.0/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.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=kvm,kernel_irqchip=split \ +-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 Index: libvirt-3.3.0/tests/qemuxml2argvtest.c =================================================================== --- libvirt-3.3.0.orig/tests/qemuxml2argvtest.c +++ libvirt-3.3.0/tests/qemuxml2argvtest.c @@ -2509,6 +2509,11 @@ mymain(void) DO_TEST("intel-iommu-machine", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_IOMMU); + DO_TEST("intel-iommu-ioapic", + QEMU_CAPS_MACHINE_OPT, + QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, + QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, + QEMU_CAPS_DEVICE_INTEL_IOMMU); DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);