From 65d89436894d5bd700b0d48cf69b49f2a375b3b8 Mon Sep 17 00:00:00 2001 Message-ID: <65d89436894d5bd700b0d48cf69b49f2a375b3b8.1734705550.git.jdenemar@redhat.com> From: Michal Privoznik Date: Wed, 18 Dec 2024 11:07:26 +0100 Subject: [PATCH] qemu: Enable I/O APIC even more frequently In my previous commit v10.10.0-48-g2d222ecf6e I've made us enable I/O APIC when there is an IOMMU with EIM. This works well. What does not work is case when there's just an IOMMU without EIM but with 256+ vCPUS. Problem is that post parsing happens in two stages: general domain post parse (where qemuDomainDefEnableDefaultFeatures() is called) and then per device post parse (where qemuDomainIOMMUDefPostParse() is called). Now, in aforementioned case it is the device post parse phase where EIM is enabled but the code that would enable VIR_DOMAIN_FEATURE_IOAPIC has already run. To resolve this, make the domain post parse callback "foresee" the future enabling of EIM so that it can turn on I/O APIC beforehand. Resolves: https://issues.redhat.com/browse/RHEL-65844 Fixes: 2d222ecf6e73614a400b830ac56e9aaa1bc55ecc Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark (cherry picked from commit 0162f2008e36df489f6f04e4d6002543acfa171d) https://issues.redhat.com/browse/RHEL-69725 Conflicts: src/qemu/qemu_postparse.c: In the downstream, postparse still lives in qemu_domain.c because v10.10.0-rc1~144 isn't backported. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 21 +++++++++--- ...m-autoadd-v2.x86_64-latest.abi-update.args | 1 + ...im-autoadd-v2.x86_64-latest.abi-update.xml | 1 + .../intel-iommu-eim-autoadd-v2.xml | 32 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 5 files changed, 51 insertions(+), 5 deletions(-) create mode 120000 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.args create mode 120000 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.xml create mode 100644 tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1ca1c6ceac..cc3b84b609 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4471,6 +4471,15 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, } +static bool +qemuDomainNeedsIOMMUWithEIM(const virDomainDef *def) +{ + return ARCH_IS_X86(def->os.arch) && + virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM && + qemuDomainIsQ35(def); +} + + /** * qemuDomainDefEnableDefaultFeatures: * @def: domain definition @@ -4533,9 +4542,13 @@ qemuDomainDefEnableDefaultFeatures(virDomainDef *def, def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; } - /* IOMMU with intremap requires split I/O APIC */ + /* IOMMU with intremap requires split I/O APIC. But it may happen that + * domain already has IOMMU without inremap. This will be fixed in + * qemuDomainIOMMUDefPostParse() but there domain definition can't be + * modified so change it now. */ if (def->iommu && - def->iommu->intremap == VIR_TRISTATE_SWITCH_ON && + (def->iommu->intremap == VIR_TRISTATE_SWITCH_ON || + qemuDomainNeedsIOMMUWithEIM(def)) && def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_DOMAIN_IOAPIC_NONE) { def->features[VIR_DOMAIN_FEATURE_IOAPIC] = VIR_DOMAIN_IOAPIC_QEMU; } @@ -6369,9 +6382,7 @@ qemuDomainIOMMUDefPostParse(virDomainIOMMUDef *iommu, * (EIM) is not explicitly turned off, let's enable it. If we didn't then * guest will have troubles with interrupts. */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE && - ARCH_IS_X86(def->os.arch) && - virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM && - qemuDomainIsQ35(def) && + qemuDomainNeedsIOMMUWithEIM(def) && iommu && iommu->model == VIR_DOMAIN_IOMMU_MODEL_INTEL) { /* eim requires intremap. */ diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.args b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.args new file mode 120000 index 0000000000..a7fdee3d71 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.args @@ -0,0 +1 @@ +intel-iommu-eim-autoadd.x86_64-latest.abi-update.args \ No newline at end of file diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.xml new file mode 120000 index 0000000000..928ea1b4c8 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.x86_64-latest.abi-update.xml @@ -0,0 +1 @@ +intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml \ No newline at end of file diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml new file mode 100644 index 0000000000..b39ee55786 --- /dev/null +++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd-v2.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 288 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + +