]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_hotplug: Remove iommufd object if no longer needed
authorPavel Hrdina <phrdina@redhat.com>
Sun, 15 Feb 2026 18:57:12 +0000 (19:57 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 16 Feb 2026 14:50:39 +0000 (15:50 +0100)
When removing last host device using IOMMUFD remove the iommufd object
as well.

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

index d17370b582766d97c0720207966acea3928351f4..24fbccccf03cb4a5b734f1a5d493ace46ec9ce4e 100644 (file)
@@ -4997,6 +4997,14 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver,
         }
     }
 
+    if (priv->iommufdState &&
+        !virDomainDefHasPCIHostdevWithIOMMUFD(vm->def)) {
+        qemuDomainObjEnterMonitor(vm);
+        ignore_value(qemuMonitorDelObject(priv->mon, "iommufd0", false));
+        qemuDomainObjExitMonitor(vm);
+        priv->iommufdState = false;
+    }
+
     virDomainAuditHostdev(vm, hostdev, "detach", true);
 
     if (!virHostdevIsPCIDevice(hostdev) &&