]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Expand call to qemuDomainNeedsVFIO
authorPavel Hrdina <phrdina@redhat.com>
Wed, 18 Mar 2026 11:52:05 +0000 (12:52 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 20 Mar 2026 10:06:40 +0000 (11:06 +0100)
The function qemuDomainNeedsVFIO() was originally used by other parts
of qemu code to figure out if the VM needs /dev/vfio/vfio.

Later it was also used by code calculating locked memory limit for all
architectures, and after that change again and used only for PPC64.

Now it needs to be changed again due to IOMMUFD support, the
/dev/vfio/vfio device is used by QEMU only if IOMMUFD is not used
but for accounting we still need consider all PCI host devices
because if IOMMUFD is used it still requires increasing locked
memory limit.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_domain.c

index 90d0f0261276a743979a3647dccfa2097a9c7e3d..cfc45e11b042734dc092151b74ba6655ac724bd2 100644 (file)
@@ -8259,8 +8259,14 @@ getPPC64MemLockLimitBytes(virDomainDef *def)
         passthroughLimit = maxMemory +
                            128 * (1ULL<<30) / 512 * nPCIHostBridges +
                            8192;
-    } else if (qemuDomainNeedsVFIO(def) || virDomainDefHasVDPANet(def)) {
-        /* For regular (non-NVLink2 present) VFIO passthrough, the value
+    } else if (virDomainDefHasPCIHostdev(def) ||
+               virDomainDefHasMdevHostdev(def) ||
+               virDomainDefHasNVMeDisk(def) ||
+               virDomainDefHasVDPANet(def)) {
+        /* Not using qemuDomainNeedsVFIO() as that doesn't take PCI host
+         * devices with IOMMFD into account.
+         *
+         * For regular (non-NVLink2 present) VFIO passthrough, the value
          * of passthroughLimit is:
          *
          * passthroughLimit := max( 2 GiB * #PHBs,                       (c)