- conf: Parse hyperv features even for host-model (RHEL-151688) - qemu: Wire up new hyperv host-model mode behavior (RHEL-151688) - Introduce EXPAND_CPU_FEATURES flag for domain capabilities (RHEL-153653) - qemu: Implement VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES (RHEL-153653) - virsh: Add --expand-cpu-features option for domcapabilities (RHEL-153653) - docs: Clarify host-model description in domain capabilities (RHEL-153653) - qemu: Fix job handling when domain dies in post-copy migration (RHEL-145179) - security_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel (RHEL-159902) - security: Cleanup hostdev label error logic (RHEL-159902) - qemu: Fix IOMMUFD and VFIO security labels (RHEL-159902) - viriommufd: Set IOMMU_OPTION_RLIMIT_MODE only when running privileged (RHEL-156803) - conf: Move and rename virStorageSourceFDTuple object (RHEL-156803) - conf: Refactor virHostdevIsPCIDevice (RHEL-156803) - hypervisor: Fix virHostdevNeedsVFIO detection (RHEL-156803) - qemu: Expand call to qemuDomainNeedsVFIO (RHEL-156803) - qemu: Update qemuDomainNeedsVFIO to ignore PCI hostdev with IOMMUFD (RHEL-156803) - src: Use virHostdevIsPCIDeviceWith* to check for IOMMUFD (RHEL-156803) - conf: Introduce domain iommufd element (RHEL-156803) - qemu: Implement iommufd (RHEL-156803) - conf: Add iommufd fdgroup support (RHEL-156803) - qemu: Implement iommufd fdgroup (RHEL-156803) - tests: Add iommufd fdgroup test (RHEL-156803) - hypervisor: Call virWaitForDevices() after detaching host devices (RHEL-156803) - qemuMigrationSrcBeginXML: Don't call 'qemuMigrationSrcBeginPhaseBlockDirtyBitmaps' with offline VM (RHEL-173433) - qemuMigrationSrcBeginPhase: Don't call 'qemuBlockNodesEnsureActive' with offline VM (RHEL-173433) - util: virGetSubIDs: do not limit file size (RHEL-174491) - cpu_conf: Introduce virCPUDefSortFeatures (RHEL-177364) - qemu_capabilities: Split virQEMUCapsFillDomainCPUCaps (RHEL-177364) - qemu: Move domain caps flags handling to virQEMUCapsFillDomainCPUHostModel (RHEL-177364) - qemu_capabilities: Always sort features in host-model CPU (RHEL-177364) - qemu_capabilities: Use g_autoptr in virQEMUCapsInitHostCPUModel (RHEL-177364) - qemu_capabilities: Split conditions in virQEMUCapsInitHostCPUModel (RHEL-177364) - qemu_capabilities: Cache expanded CPU (RHEL-177364) - domaincapstest: Test EXPAND_CPU_FEATURES flag (RHEL-177364) - util: Publish and mock virHostCPUGetMSRFromKVM (RHEL-177364) - cpu_x86: Introduce virCPUx86DataAddMSR (RHEL-177364) - cpu: Introduce virCPUUpdateFeatures (RHEL-177364) - Fix documentation of VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES (RHEL-177364) - Introduce VIR_CONNECT_GET_DOMAIN_CAPABILITIES_SUPPORTED_CPU_FEATURES flag (RHEL-177364) - virsh: Add --supported-cpu-features option for domcapabilities (RHEL-177364) - domaincapstest: Test SUPPORTED_CPU_FEATURES flag (RHEL-177364) - qemu_capabilities: Fix domain capabilities on AMD CPUs (RHEL-177364) - distro: Replace old gating with tmt Resolves: RHEL-145179, RHEL-151688, RHEL-153653, RHEL-156803, RHEL-159902 Resolves: RHEL-173433, RHEL-174491, RHEL-177364
128 lines
4.2 KiB
Diff
128 lines
4.2 KiB
Diff
From 8cdc3bb132898c37fe17762aba7dabb59819ce0a Mon Sep 17 00:00:00 2001
|
|
Message-ID: <8cdc3bb132898c37fe17762aba7dabb59819ce0a.1780571166.git.jdenemar@redhat.com>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Mon, 16 Mar 2026 15:29:32 +0100
|
|
Subject: [PATCH] qemu: Implement iommufd fdgroup
|
|
|
|
When fdgroup is used for iommufd we will start QEMU with -object iommufd
|
|
even if the VM has no host device. When virDomainFDAssociate() is used
|
|
the FD libvirt is holding is closed with connection.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
(cherry picked from commit 0a83b28795f0c18592f9d842927528f0676cc56d)
|
|
|
|
Resolves: https://redhat.atlassian.net/browse/RHEL-156803
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
---
|
|
src/qemu/qemu_command.c | 4 +++-
|
|
src/qemu/qemu_hotplug.c | 4 ++--
|
|
src/qemu/qemu_process.c | 47 ++++++++++++++++++++++++++++++++++++++---
|
|
3 files changed, 49 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
index 23e799de3c..db72407ecc 100644
|
|
--- a/src/qemu/qemu_command.c
|
|
+++ b/src/qemu/qemu_command.c
|
|
@@ -5360,8 +5360,10 @@ qemuBuildIOMMUFDCommandLine(virCommand *cmd,
|
|
qemuDomainObjPrivate *priv = vm->privateData;
|
|
g_autoptr(virJSONValue) props = NULL;
|
|
|
|
- if (!virDomainDefHasPCIHostdevWithIOMMUFD(def))
|
|
+ if (!virDomainDefHasPCIHostdevWithIOMMUFD(def) &&
|
|
+ !def->iommufd_fdgroup) {
|
|
return 0;
|
|
+ }
|
|
|
|
qemuFDPassDirectTransferCommand(priv->iommufd, cmd);
|
|
|
|
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
index 25fe699bb3..8944062aa4 100644
|
|
--- a/src/qemu/qemu_hotplug.c
|
|
+++ b/src/qemu/qemu_hotplug.c
|
|
@@ -1624,7 +1624,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
|
|
if (qemuProcessOpenVfioDeviceFd(vm, hostdev) < 0)
|
|
goto error;
|
|
|
|
- if (!priv->iommufdState) {
|
|
+ if (!priv->iommufdState && !vm->def->iommufd_fdgroup) {
|
|
if (qemuProcessOpenIommuFd(vm) < 0)
|
|
goto error;
|
|
|
|
@@ -5031,7 +5031,7 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver,
|
|
}
|
|
}
|
|
|
|
- if (priv->iommufdState &&
|
|
+ if (priv->iommufdState && !vm->def->iommufd_fdgroup &&
|
|
!virDomainDefHasPCIHostdevWithIOMMUFD(vm->def)) {
|
|
qemuDomainObjEnterMonitor(vm);
|
|
ignore_value(qemuMonitorDelObject(priv->mon, "iommufd0", false));
|
|
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
index d13bce8fcf..e4746374f6 100644
|
|
--- a/src/qemu/qemu_process.c
|
|
+++ b/src/qemu/qemu_process.c
|
|
@@ -7706,6 +7706,44 @@ qemuProcessOpenIommuFd(virDomainObj *vm)
|
|
return 0;
|
|
}
|
|
|
|
+/**
|
|
+ * qemuProcessGetPassedIommuFd:
|
|
+ * @vm: domain object
|
|
+ *
|
|
+ * Find passed FD via virDomainFDAssociate() API for the VM.
|
|
+ *
|
|
+ * Returns: 0 on success, -1 on failure
|
|
+ */
|
|
+static int
|
|
+qemuProcessGetPassedIommuFd(virDomainObj *vm)
|
|
+{
|
|
+ qemuDomainObjPrivate *priv = vm->privateData;
|
|
+ virDomainFDTuple *fdt = virHashLookup(priv->fds, vm->def->iommufd_fdgroup);
|
|
+ VIR_AUTOCLOSE iommufd = -1;
|
|
+
|
|
+ if (!fdt) {
|
|
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
+ _("file descriptor group '%1$s' was not associated with the domain"),
|
|
+ vm->def->iommufd_fdgroup);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (fdt->nfds != 1) {
|
|
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
+ _("Only one file descriptor needs to be associated with iommufd"));
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ iommufd = dup(fdt->fds[0]);
|
|
+
|
|
+ if (qemuSecuritySetImageFDLabel(priv->driver->securityManager, vm->def, iommufd) < 0)
|
|
+ return -1;
|
|
+
|
|
+ priv->iommufd = qemuFDPassDirectNew("iommufd", &iommufd);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
/**
|
|
* qemuProcessOpenVfioDeviceFd:
|
|
* @hostdev: host device definition
|
|
@@ -7761,9 +7799,12 @@ qemuProcessPrepareHostHostdev(virDomainObj *vm)
|
|
}
|
|
|
|
/* Open IOMMU FD */
|
|
- if (virDomainDefHasPCIHostdevWithIOMMUFD(vm->def) &&
|
|
- qemuProcessOpenIommuFd(vm) < 0) {
|
|
- return -1;
|
|
+ if (vm->def->iommufd_fdgroup) {
|
|
+ if (qemuProcessGetPassedIommuFd(vm) < 0)
|
|
+ return -1;
|
|
+ } else if (virDomainDefHasPCIHostdevWithIOMMUFD(vm->def)) {
|
|
+ if (qemuProcessOpenIommuFd(vm) < 0)
|
|
+ return -1;
|
|
}
|
|
|
|
return 0;
|
|
--
|
|
2.54.0
|