]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_cgroup.c: skip absent PCI devices in qemuTeardownHostdevCgroup()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 4 Jan 2021 12:54:39 +0000 (09:54 -0300)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 1 Mar 2021 15:25:33 +0000 (12:25 -0300)
There is no need to bother with cgroup tearing down for absent
PCI devices, given that their entries in the sysfs are already
gone.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_cgroup.c

index 39c83d1478af236cf7b8dec5fb25f59f9b4c1a95..8c31bb4210bde8db720a1fdcd3c0ec46ca4a543f 100644 (file)
@@ -467,6 +467,16 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
     if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
         return 0;
 
+    /* Skip tearing down Cgroup for hostdevs that represents absent
+     * PCI devices, e.g. SR-IOV virtual functions that were removed from
+     * the host while the domain was still running. */
+    if (virHostdevIsPCIDevice(dev)) {
+        const virDomainHostdevSubsysPCI *pcisrc = &dev->source.subsys.u.pci;
+
+        if (!virPCIDeviceExists(&pcisrc->addr))
+            return 0;
+    }
+
     if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
         return -1;