]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_command: Don't use host property if IOMMUFD is used
authorPavel Hrdina <phrdina@redhat.com>
Sun, 15 Feb 2026 18:49:16 +0000 (19:49 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 16 Feb 2026 14:50:39 +0000 (15:50 +0100)
They should not be used at the same time.

Fixes: f6230804727df834da27370e835204672218ab23
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
tests/qemuxmlconfdata/iommufd-q35.x86_64-latest.args
tests/qemuxmlconfdata/iommufd-virt-pci-bus-single.aarch64-latest.args
tests/qemuxmlconfdata/iommufd-virt.aarch64-latest.args
tests/qemuxmlconfdata/iommufd.x86_64-latest.args

index 91eb3cb27dc87c92fe5aba21c60da82a1ef4074c..724f0cd8ebae5b95ba4093941487ea394108791c 100644 (file)
@@ -4762,10 +4762,11 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
     g_autoptr(virJSONValue) props = NULL;
     virDomainHostdevSubsysPCI *pcisrc = &dev->source.subsys.u.pci;
     virDomainNetTeamingInfo *teaming;
-    g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr);
+    g_autofree char *host = NULL;
     const char *failover_pair_id = NULL;
     const char *driver = NULL;
     const char *iommufdId = NULL;
+    const char *fdstr = NULL;
     /* 'ramfb' property must be omitted unless it's to be enabled */
     bool ramfb = pcisrc->ramfb == VIR_TRISTATE_SWITCH_ON;
 
@@ -4799,31 +4800,28 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
         teaming->persistent)
         failover_pair_id = teaming->persistent;
 
-    if (pcisrc->driver.iommufd == VIR_TRISTATE_BOOL_YES)
+    if (virHostdevIsPCIDeviceWithIOMMUFD(dev)) {
+        qemuDomainHostdevPrivate *hostdevPriv = QEMU_DOMAIN_HOSTDEV_PRIVATE(dev);
+
+        fdstr = qemuFDPassDirectGetPath(hostdevPriv->vfioDeviceFd);
         iommufdId = "iommufd0";
+    } else {
+        host = virPCIDeviceAddressAsString(&pcisrc->addr);
+    }
 
     if (virJSONValueObjectAdd(&props,
                               "s:driver", driver,
-                              "s:host", host,
+                              "S:host", host,
                               "s:id", dev->info->alias,
                               "p:bootindex", dev->info->effectiveBootIndex,
                               "S:failover_pair_id", failover_pair_id,
                               "S:display", qemuOnOffAuto(pcisrc->display),
                               "B:ramfb", ramfb,
                               "S:iommufd", iommufdId,
+                              "S:fd", fdstr,
                               NULL) < 0)
         return NULL;
 
-    if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO &&
-        pcisrc->driver.iommufd == VIR_TRISTATE_BOOL_YES) {
-        qemuDomainHostdevPrivate *hostdevPriv = QEMU_DOMAIN_HOSTDEV_PRIVATE(dev);
-
-        if (virJSONValueObjectAdd(&props,
-                                  "S:fd", qemuFDPassDirectGetPath(hostdevPriv->vfioDeviceFd),
-                                  NULL) < 0)
-            return NULL;
-    }
-
     if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0)
         return NULL;
 
index d5fe7040219071558502dc9b334bcdf9172a9d43..f886c488e1f24ad2005f56f0230f673cba4e57a4 100644 (file)
@@ -36,6 +36,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-q35-test/.config \
 -global ICH9-LPC.noreboot=off \
 -watchdog-action reset \
 -object '{"qom-type":"iommufd","id":"iommufd0","fd":"0"}' \
--device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pcie.0","addr":"0x3"}' \
+-device '{"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pcie.0","addr":"0x3"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index 303cfa922bd38991e9bc4f950b89504b0b4eaad0..543e976c583eabf50f8c0ff9d1a43a17f2c6412a 100644 (file)
@@ -27,6 +27,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
 -boot strict=on \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -object '{"qom-type":"iommufd","id":"iommufd0","fd":"0"}' \
--device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pcie.0","addr":"0x1"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index 6a62b08e8a4721bb2e17a66042148fbe6e7ee3ee..e1a4c4bb9a80f73af8096d2e5f747e652f3e5313 100644 (file)
@@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
 -device '{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x2"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -object '{"qom-type":"iommufd","id":"iommufd0","fd":"0"}' \
--device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pci.1","addr":"0x0"}' \
--device '{"driver":"vfio-pci","host":"0000:07:12.5","id":"hostdev1","iommufd":"iommufd0","fd":"0","bus":"pci.2","addr":"0x0"}' \
+-device '{"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pci.1","addr":"0x0"}' \
+-device '{"driver":"vfio-pci","id":"hostdev1","iommufd":"iommufd0","fd":"0","bus":"pci.2","addr":"0x0"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index 15dabe197c41cb098ea9de58df47abfd6753ddd8..b9aefda39d466a0b46dad76c742c4d8fc49aa121 100644 (file)
@@ -29,7 +29,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
 -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -object '{"qom-type":"iommufd","id":"iommufd0","fd":"0"}' \
--device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pci.0","addr":"0x3"}' \
+-device '{"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"0","bus":"pci.0","addr":"0x3"}' \
 -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on