From: Daniel Henrique Barboza Date: Mon, 4 Jan 2021 12:54:39 +0000 (-0300) Subject: qemu_cgroup.c: skip absent PCI devices in qemuTeardownHostdevCgroup() X-Git-Tag: v7.2.0-rc1~319 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67357e5094f662e6a943d421b2d7dcd494785c08;p=thirdparty%2Flibvirt.git qemu_cgroup.c: skip absent PCI devices in qemuTeardownHostdevCgroup() 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 Signed-off-by: Daniel Henrique Barboza --- diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 39c83d1478..8c31bb4210 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -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;