import OL libvirt-10.5.0-7.4.0.1.el9_5

This commit is contained in:
eabdullin 2025-02-05 12:49:42 +03:00
parent 4244b3f40d
commit d3daf844ed
6 changed files with 630 additions and 2 deletions

View File

@ -0,0 +1,32 @@
From d0cbc2e55ad6669dd1011b421d70411f47ef68d4 Mon Sep 17 00:00:00 2001
Message-ID: <d0cbc2e55ad6669dd1011b421d70411f47ef68d4.1733398772.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Wed, 6 Nov 2024 12:59:02 +0100
Subject: [PATCH] libvirt_private.syms: Export virDomainIOMMUDefNew()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit a9797d7c433c84d1d8287a3708ed54e4bcb6727c)
Resolves: https://issues.redhat.com/browse/RHEL-69725
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/libvirt_private.syms | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f7a0a8bc36..09c3e2a354 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -489,6 +489,7 @@ virDomainInputSourceGrabTypeFromString;
virDomainInputSourceGrabTypeToString;
virDomainInputTypeToString;
virDomainIOMMUDefFree;
+virDomainIOMMUDefNew;
virDomainIOMMUModelTypeFromString;
virDomainIOMMUModelTypeToString;
virDomainIOThreadIDAdd;
--
2.47.0

View File

@ -0,0 +1,160 @@
From 65d89436894d5bd700b0d48cf69b49f2a375b3b8 Mon Sep 17 00:00:00 2001
Message-ID: <65d89436894d5bd700b0d48cf69b49f2a375b3b8.1734705550.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
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 <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(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 <mprivozn@redhat.com>
---
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 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>288</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='usb' index='0' model='none'/>
+ <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'/>
+ <iommu model="intel"/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 79a5c1c1e1..3e60116b62 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -2773,6 +2773,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("intel-iommu-aw-bits");
DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
DO_TEST_CAPS_LATEST_ABI_UPDATE("intel-iommu-eim-autoadd");
+ DO_TEST_CAPS_LATEST_ABI_UPDATE("intel-iommu-eim-autoadd-v2");
DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
DO_TEST_CAPS_LATEST("virtio-iommu-x86_64");
DO_TEST_CAPS_VER_PARSE_ERROR("virtio-iommu-x86_64", "6.1.0");
--
2.47.1

View File

@ -0,0 +1,67 @@
From 053ae17ed2d2428410413b7bd5c583cd68cb1396 Mon Sep 17 00:00:00 2001
Message-ID: <053ae17ed2d2428410413b7bd5c583cd68cb1396.1734705550.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 12 Dec 2024 10:02:43 +0100
Subject: [PATCH] qemu: Enable I/O APIC if needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a follow up of my previous commits. If the number of
vCPUs exceeds some arbitrary value (255) then QEMU requires IOMMU
with EIM and intremap enabled. But in turn, intremap IOMMU
requires split I/O APIC (per virDomainDefIOMMUValidate()). Since
after my previous commits (e.g. v10.10.0-rc1~183) IOMMU is added
automagically, the I/O APIC can be also enabled automagically.
Relates to: https://issues.redhat.com/browse/RHEL-65844
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 2d222ecf6e73614a400b830ac56e9aaa1bc55ecc)
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 <mprivozn@redhat.com>
---
src/qemu/qemu_domain.c | 7 +++++++
tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml | 3 ---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 16fcdefbf0..1ca1c6ceac 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4532,6 +4532,13 @@ qemuDomainDefEnableDefaultFeatures(virDomainDef *def,
* capabilities, we still want to enable this */
def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON;
}
+
+ /* IOMMU with intremap requires split I/O APIC */
+ if (def->iommu &&
+ def->iommu->intremap == VIR_TRISTATE_SWITCH_ON &&
+ def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_DOMAIN_IOAPIC_NONE) {
+ def->features[VIR_DOMAIN_FEATURE_IOAPIC] = VIR_DOMAIN_IOAPIC_QEMU;
+ }
}
diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
index fa3aaf0d44..5abc40e566 100644
--- a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
+++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
@@ -8,9 +8,6 @@
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
</os>
- <features>
- <ioapic driver='qemu'/>
- </features>
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model>
</cpu>
--
2.47.1

View File

@ -0,0 +1,265 @@
From f945c27315df56d44e76d6c66f8b87dc0d29e38e Mon Sep 17 00:00:00 2001
Message-ID: <f945c27315df56d44e76d6c66f8b87dc0d29e38e.1733398772.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Wed, 6 Nov 2024 12:34:42 +0100
Subject: [PATCH] qemu: Turn EIM IOMMU on automagically
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If a Q35 domain has huge number of vCPUS (over 255, currently), then
it needs IOMMU with Extended Interrupt Mode enabled (see check in
qemuValidateDomainVCpuTopology()).
Well, we already add some devices and to other tricks when
parsing new domain XML. Might as well turn the EIM on for IOMMU
device.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit b15047ff2690428fefea80a455a5e8a17767e162)
Resolves: https://issues.redhat.com/browse/RHEL-69725
Conflicts:
src/qemu/qemu_domain.c: Context, since v10.6.0~12 is not
backported.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_domain.c | 37 ++++++++++++++++++-
src/qemu/qemu_validate.c | 1 -
src/qemu/qemu_validate.h | 2 +
...-eim-autoadd.x86_64-latest.abi-update.args | 34 +++++++++++++++++
...u-eim-autoadd.x86_64-latest.abi-update.xml | 37 +++++++++++++++++++
.../intel-iommu-eim-autoadd.xml | 35 ++++++++++++++++++
tests/qemuxmlconftest.c | 1 +
7 files changed, 145 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.args
create mode 100644 tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml
create mode 100644 tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c7dedf88b1..97e7ca5139 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6332,6 +6332,37 @@ qemuDomainMemoryDefPostParse(virDomainMemoryDef *mem, virArch arch,
}
+static int
+qemuDomainIOMMUDefPostParse(virDomainIOMMUDef *iommu,
+ const virDomainDef *def,
+ virQEMUCaps *qemuCaps,
+ unsigned int parseFlags)
+{
+ /* In case domain has huge number of vCPUS and Extended Interrupt Mode
+ * (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) &&
+ iommu && iommu->model == VIR_DOMAIN_IOMMU_MODEL_INTEL) {
+
+ /* eim requires intremap. */
+ if (iommu->intremap == VIR_TRISTATE_SWITCH_ABSENT &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_INTREMAP)) {
+ iommu->intremap = VIR_TRISTATE_SWITCH_ON;
+ }
+
+ if (iommu->eim == VIR_TRISTATE_SWITCH_ABSENT &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_EIM)) {
+ iommu->eim = VIR_TRISTATE_SWITCH_ON;
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
const virDomainDef *def,
@@ -6393,6 +6424,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
parseFlags);
break;
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ ret = qemuDomainIOMMUDefPostParse(dev->data.iommu, def,
+ qemuCaps, parseFlags);
+ break;
+
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
@@ -6405,7 +6441,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_RNG:
- case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_AUDIO:
case VIR_DOMAIN_DEVICE_CRYPTO:
ret = 0;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index f3d512acf7..02fd224a49 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -31,7 +31,6 @@
#include "virutil.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
-#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
VIR_LOG_INIT("qemu.qemu_validate");
diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h
index e06a43b8e3..9315be73f5 100644
--- a/src/qemu/qemu_validate.h
+++ b/src/qemu/qemu_validate.h
@@ -22,6 +22,8 @@
#include "qemu_capabilities.h"
+#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
+
int
qemuValidateDomainDef(const virDomainDef *def,
void *opaque,
diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.args b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.args
new file mode 100644
index 0000000000..07fa1191b7
--- /dev/null
+++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.args
@@ -0,0 +1,34 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine q35,usb=off,kernel_irqchip=split,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 288,sockets=288,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device '{"driver":"intel-iommu","id":"iommu0","intremap":"on","eim":"on"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-global ICH9-LPC.noreboot=off \
+-watchdog-action reset \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml
new file mode 100644
index 0000000000..1caa0ceb60
--- /dev/null
+++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.x86_64-latest.abi-update.xml
@@ -0,0 +1,37 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>288</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <ioapic driver='qemu'/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='usb' index='0' model='none'/>
+ <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'/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ <iommu model='intel'>
+ <driver intremap='on' eim='on'/>
+ </iommu>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
new file mode 100644
index 0000000000..7c294fe2f9
--- /dev/null
+++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
@@ -0,0 +1,35 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>288</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <ioapic driver='qemu'/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='usb' index='0' model='none'/>
+ <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'/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ <iommu model='intel'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 338462193b..79a5c1c1e1 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -2772,6 +2772,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb");
DO_TEST_CAPS_LATEST("intel-iommu-aw-bits");
DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
+ DO_TEST_CAPS_LATEST_ABI_UPDATE("intel-iommu-eim-autoadd");
DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
DO_TEST_CAPS_LATEST("virtio-iommu-x86_64");
DO_TEST_CAPS_VER_PARSE_ERROR("virtio-iommu-x86_64", "6.1.0");
--
2.47.0

View File

@ -0,0 +1,86 @@
From 21a5e5cd2a5c8030453eed7ad3e84d244429d403 Mon Sep 17 00:00:00 2001
Message-ID: <21a5e5cd2a5c8030453eed7ad3e84d244429d403.1733398772.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Wed, 6 Nov 2024 12:57:21 +0100
Subject: [PATCH] qemu_domain: Automagically add IOMMU if needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If a Q35 domain has huge number of vCPUS (over 255, currently), then
it needs IOMMU with Extended Interrupt Mode enabled (see check in
qemuValidateDomainVCpuTopology()).
Well, we already add some devices and to other tricks when
parsing new domain XML. Might as well add IOMMU device if above
condition is met.
Resolves: https://issues.redhat.com/browse/RHEL-65844
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 844d1036eb734b6c80397a0c69f491645c682313)
Resolves: https://issues.redhat.com/browse/RHEL-69725
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_domain.c | 20 +++++++++++++++++++
.../intel-iommu-eim-autoadd.xml | 1 -
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 97e7ca5139..16fcdefbf0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4176,6 +4176,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
bool addDefaultUSBMouse = false;
bool addPanicDevice = false;
bool addITCOWatchdog = false;
+ bool addIOMMU = false;
/* add implicit input devices */
if (qemuDomainDefAddImplicitInputDevice(def) < 0)
@@ -4198,6 +4199,10 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
addImplicitSATA = true;
addITCOWatchdog = true;
+ if (virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
+ addIOMMU = true;
+ }
+
/* Prefer adding a USB3 controller if supported, fall back
* to USB2 if there is no USB3 available, and if that's
* unavailable don't add anything.
@@ -4444,6 +4449,21 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
}
}
+ if (addIOMMU && !def->iommu &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU) &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_INTREMAP) &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_EIM)) {
+ g_autoptr(virDomainIOMMUDef) iommu = NULL;
+
+ iommu = virDomainIOMMUDefNew();
+ iommu->model = VIR_DOMAIN_IOMMU_MODEL_INTEL;
+ /* eim requires intremap. */
+ iommu->intremap = VIR_TRISTATE_SWITCH_ON;
+ iommu->eim = VIR_TRISTATE_SWITCH_ON;
+
+ def->iommu = g_steal_pointer(&iommu);
+ }
+
if (qemuDomainDefAddDefaultAudioBackend(driver, def) < 0)
return -1;
diff --git a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
index 7c294fe2f9..fa3aaf0d44 100644
--- a/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
+++ b/tests/qemuxmlconfdata/intel-iommu-eim-autoadd.xml
@@ -30,6 +30,5 @@
<audio id='1' type='none'/>
<watchdog model='itco' action='reset'/>
<memballoon model='none'/>
- <iommu model='intel'/>
</devices>
</domain>
--
2.47.0

View File

@ -289,7 +289,7 @@
Summary: Library providing a simple virtualization API Summary: Library providing a simple virtualization API
Name: libvirt Name: libvirt
Version: 10.5.0 Version: 10.5.0
Release: 7.2%{?dist}%{?extra_release} Release: 7.4.0.1%{?dist}%{?extra_release}
License: GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OFL-1.1 License: GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OFL-1.1
URL: https://libvirt.org/ URL: https://libvirt.org/
@ -334,6 +334,11 @@ Patch34: libvirt-util-Look-for-newer-name-of-cpu-wait-time-statistic.patch
Patch35: libvirt-vmx-Allow-to-appear-in-VMX-file-keys.patch Patch35: libvirt-vmx-Allow-to-appear-in-VMX-file-keys.patch
Patch36: libvirt-qemu-Add-support-for-postcopy-recover-setup-migration-state.patch Patch36: libvirt-qemu-Add-support-for-postcopy-recover-setup-migration-state.patch
Patch37: libvirt-qemu-Avoid-false-failure-when-resuming-post-copy-migration.patch Patch37: libvirt-qemu-Avoid-false-failure-when-resuming-post-copy-migration.patch
Patch38: libvirt-libvirt_private.syms-Export-virDomainIOMMUDefNew.patch
Patch39: libvirt-qemu-Turn-EIM-IOMMU-on-automagically.patch
Patch40: libvirt-qemu_domain-Automagically-add-IOMMU-if-needed.patch
Patch41: libvirt-qemu-Enable-I-O-APIC-if-needed.patch
Patch42: libvirt-qemu-Enable-I-O-APIC-even-more-frequently.patch
Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon = %{version}-%{release}
@ -1358,7 +1363,8 @@ exit 1
%define arg_packager_version -Dpackager_version="%{release}" %define arg_packager_version -Dpackager_version="%{release}"
%define arg_selinux_mount -Dselinux_mount="/sys/fs/selinux" %define arg_selinux_mount -Dselinux_mount="/sys/fs/selinux"
# place macros above and build commands below this comment # Set SOURCE_DATE_EPOCH from changelog
%define source_date_epoch_from_changelog 1
export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
@ -2662,6 +2668,18 @@ exit 0
%endif %endif
%changelog %changelog
* Mon Feb 03 2025 EL Errata <el-errata_ww@oracle.com> - 10.5.0-7.4.0.1
- Set SOURCE_DATE_EPOCH from changelog [Orabug: 32019554]
* Fri Dec 20 2024 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.4.el9_5
- qemu: Enable I/O APIC if needed (RHEL-69725)
- qemu: Enable I/O APIC even more frequently (RHEL-69725)
* Thu Dec 5 2024 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.3.el9_5
- libvirt_private.syms: Export virDomainIOMMUDefNew() (RHEL-69725)
- qemu: Turn EIM IOMMU on automagically (RHEL-69725)
- qemu_domain: Automagically add IOMMU if needed (RHEL-69725)
* Mon Nov 4 2024 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.2.el9_5 * Mon Nov 4 2024 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.2.el9_5
- qemu: Add support for postcopy-recover-setup migration state (RHEL-63877) - qemu: Add support for postcopy-recover-setup migration state (RHEL-63877)
- qemu: Avoid false failure when resuming post-copy migration (RHEL-63877) - qemu: Avoid false failure when resuming post-copy migration (RHEL-63877)