- qemu: Introduce QEMU_CAPS_OBJECT_IOMMUFD (RHEL-150353) - qemu: Move IOMMUFD validation to qemu_validate (RHEL-150353) - util: Move openning IOMMU device to viriommufd (RHEL-150353) - qemu_process: Refactor qemuProcessOpenIommuFd (RHEL-150353) - util: Move openning VFIO device to virpci (RHEL-150353) - qemu_process: Refactor qemuProcessOpenVfioDeviceFd (RHEL-150353) - util: Use virPCIDevice as argument in virPCIDeviceGetVfioPath (RHEL-150353) - conf: Introduce virHostdevIsPCIDeviceWithIOMMUFD (RHEL-150353) - conf: Introduce virDomainDefHasPCIHostdevWithIOMMUFD (RHEL-150353) - qemu_domain: Add missing IOMMUFD cleanup (RHEL-150353) - qemu_process: Fix FD leak with multiple host devices using IOMMUFD (RHEL-150353) - qemu_process: Refactor qemuProcessOpenVfioFds (RHEL-150353) - qemuxmlconftest: Refactor host device preparation (RHEL-150353) - qemuxmlconftest: Rename and refactor testSetupHostdevPrivateData (RHEL-150353) - qemuxmlconftest: Set fake FD for IOMMUFD (RHEL-150353) - qemu: Convert IOMMUFD to qemuFDPassDirect (RHEL-150353) - qemu: Convert vfioDeviceFd to qemuFDPassDirect (RHEL-150353) - qemu_command: Don't use host property if IOMMUFD is used (RHEL-150353) - qemu: Save IOMMUFD state into status XML (RHEL-150353) - qemu_hotplug: Remove iommufd object if no longer needed (RHEL-150353) - qemu_command: Extract building IOMMUFD props to function (RHEL-150353) - qemu_hotplug: Add support to hotplug host device with IOMMUFD (RHEL-150353) - conf: Introduce iommufd enum for domaincaps (RHEL-138544) - qemu: Fill iommufd domain capability (RHEL-138544) - tests: properly mock VFIO and IOMMU checks (RHEL-138544) - iommufd: fix FD leak in case of error (RHEL-150353) Resolves: RHEL-138544, RHEL-150353
102 lines
3.2 KiB
Diff
102 lines
3.2 KiB
Diff
From 276b0655a20762b1267a9e4212d266d632633103 Mon Sep 17 00:00:00 2001
|
|
Message-ID: <276b0655a20762b1267a9e4212d266d632633103.1771423832.git.jdenemar@redhat.com>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Sat, 14 Feb 2026 11:39:19 +0100
|
|
Subject: [PATCH] qemuxmlconftest: Refactor host device preparation
|
|
|
|
Create a single place for host device preparation code.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
(cherry picked from commit cb23831c020a5fab33be417426b2746a73ecdd10)
|
|
|
|
Conflicts:
|
|
- missing upstream commit b97afe28f54dae1d122baa33d1a371b68775b7b2
|
|
tests/qemuxmlconftest.c
|
|
|
|
Resolves: https://issues.redhat.com/browse/RHEL-150353
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
---
|
|
tests/qemuxmlconftest.c | 59 ++++++++++++++++++++++++++++++-----------
|
|
1 file changed, 43 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
|
|
index 27e63cff24..7c2dc3697b 100644
|
|
--- a/tests/qemuxmlconftest.c
|
|
+++ b/tests/qemuxmlconftest.c
|
|
@@ -378,6 +378,48 @@ testSetupHostdevPrivateData(virDomainDef *def)
|
|
}
|
|
|
|
|
|
+static void
|
|
+testQemuPrepareHostdevUSB(virDomainHostdevDef *hostdev)
|
|
+{
|
|
+ virDomainHostdevSubsysUSB *usb = &hostdev->source.subsys.u.usb;
|
|
+
|
|
+ if (!usb->device && !usb->bus) {
|
|
+ if (usb->vendor == 0x1234 && usb->product == 0x4321) {
|
|
+ usb->bus = 42;
|
|
+ usb->device = 0x1234;
|
|
+ } else {
|
|
+ g_assert_not_reached();
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
+
|
|
+static void
|
|
+testQemuPrepareHostdev(virDomainObj *vm)
|
|
+{
|
|
+ size_t i;
|
|
+
|
|
+ for (i = 0; i < vm->def->nhostdevs; i++) {
|
|
+ virDomainHostdevDef *hostdev = vm->def->hostdevs[i];
|
|
+
|
|
+ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
|
+ continue;
|
|
+
|
|
+ switch (hostdev->source.subsys.type) {
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
|
+ testQemuPrepareHostdevUSB(hostdev);
|
|
+ break;
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
|
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
+
|
|
static virNetworkDriver fakeNetworkDriver = {
|
|
.networkLookupByName = fakeNetworkLookupByName,
|
|
.networkGetXMLDesc = fakeNetworkGetXMLDesc,
|
|
@@ -524,22 +566,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv,
|
|
}
|
|
}
|
|
|
|
- for (i = 0; i < vm->def->nhostdevs; i++) {
|
|
- virDomainHostdevDef *hostdev = vm->def->hostdevs[i];
|
|
-
|
|
- if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
|
- hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
|
- virDomainHostdevSubsysUSB *usb = &hostdev->source.subsys.u.usb;
|
|
- if (!usb->device && !usb->bus) {
|
|
- if (usb->vendor == 0x1234 && usb->product == 0x4321) {
|
|
- usb->bus = 42;
|
|
- usb->device = 0x1234;
|
|
- } else {
|
|
- g_assert_not_reached();
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
+ testQemuPrepareHostdev(vm);
|
|
|
|
if (flags & FLAG_SLIRP_HELPER) {
|
|
for (i = 0; i < vm->def->nnets; i++) {
|
|
--
|
|
2.53.0
|