If the underlying PCI device of a hostdev does not exist in the
host (e.g. a SR-IOV VF that was removed while the domain was
running), skip security label handling for it.
This will avoid errors that happens during qemuProcessStop() time,
where a VF that was being used by the domain is not present anymore.
The restore label functions of both DAC and SELinux drivers will
trigger errors in virPCIDeviceNew().
Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
- g_autoptr(virPCIDevice) pci = virPCIDeviceNew(&pcisrc->addr);
+ g_autoptr(virPCIDevice) pci = NULL;
+
+ if (!virPCIDeviceExists(&pcisrc->addr))
+ break;
+
+ pci = virPCIDeviceNew(&pcisrc->addr);
if (!pci)
return -1;
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
- g_autoptr(virPCIDevice) pci = virPCIDeviceNew(&pcisrc->addr);
+ g_autoptr(virPCIDevice) pci = NULL;
+
+ if (!virPCIDeviceExists(&pcisrc->addr))
+ break;
+
+ pci = virPCIDeviceNew(&pcisrc->addr);
if (!pci)
return -1;
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
- g_autoptr(virPCIDevice) pci = virPCIDeviceNew(&pcisrc->addr);
+ g_autoptr(virPCIDevice) pci = NULL;
+
+ if (!virPCIDeviceExists(&pcisrc->addr))
+ break;
+
+ pci = virPCIDeviceNew(&pcisrc->addr);
if (!pci)
return -1;
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
- g_autoptr(virPCIDevice) pci = virPCIDeviceNew(&pcisrc->addr);
+ g_autoptr(virPCIDevice) pci = NULL;
+
+ if (!virPCIDeviceExists(&pcisrc->addr))
+ break;
+
+ pci = virPCIDeviceNew(&pcisrc->addr);
if (!pci)
return -1;