]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_process: Fix FD leak with multiple host devices using IOMMUFD
authorPavel Hrdina <phrdina@redhat.com>
Sun, 15 Feb 2026 18:13:19 +0000 (19:13 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 16 Feb 2026 14:50:39 +0000 (15:50 +0100)
We would open IOMMU device for each host device with IOMMUFD backend
leaking FD except for the last one. Since we are adding only single
iommufd object we need to open it only once.

Fixes: 2f0999a161910e3992458902ce90d37f8b8f2642
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_process.c

index cfc30dcbe4989a5537b8ff56543ec13ecf69579e..1ca0ed1b9bd3e05ba89ac3b5124eaee1dcea15c0 100644 (file)
@@ -7740,13 +7740,15 @@ qemuProcessOpenVfioFds(virDomainObj *vm)
             /* Open VFIO device FD */
             if (qemuProcessOpenVfioDeviceFd(hostdev) < 0)
                 return -1;
-
-            /* Open IOMMU FD */
-            if (qemuProcessOpenIommuFd(vm) < 0)
-                return -1;
         }
     }
 
+    /* Open IOMMU FD */
+    if (virDomainDefHasPCIHostdevWithIOMMUFD(vm->def) &&
+        qemuProcessOpenIommuFd(vm) < 0) {
+        return -1;
+    }
+
     return 0;
 }