mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
virhostdev: Check driver name too in virHostdevIsPCINodeDeviceUsed()
It may happen that there are two domains with the same name in two separate drivers (e.g. qemu and lxc). That is why for PCI devices we track both names of driver and domain combination which has taken the device. However, when we check if given PCI device is in use (or PCI devices from the same IOMMU group) we compare only domain name. This means that we can mistakenly claim device as free to use while in fact it isn't. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
324b576c0c
commit
a307143ee7
@ -51,6 +51,7 @@ static virHostdevManagerPtr virHostdevManagerNew(void);
|
||||
|
||||
struct virHostdevIsPCINodeDeviceUsedData {
|
||||
virHostdevManagerPtr mgr;
|
||||
const char *driverName;
|
||||
const char *domainName;
|
||||
const bool usesVFIO;
|
||||
};
|
||||
@ -91,8 +92,8 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddressPtr devAddr, void *o
|
||||
virPCIDeviceGetUsedBy(actual, &actual_drvname, &actual_domname);
|
||||
|
||||
if (helperData->usesVFIO &&
|
||||
(actual_domname && helperData->domainName) &&
|
||||
(STREQ(actual_domname, helperData->domainName)))
|
||||
STREQ_NULLABLE(actual_drvname, helperData->driverName) &&
|
||||
STREQ_NULLABLE(actual_domname, helperData->domainName))
|
||||
goto iommu_owner;
|
||||
|
||||
if (actual_drvname && actual_domname)
|
||||
@ -706,7 +707,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
|
||||
virPCIDevicePtr pci = virPCIDeviceListGet(pcidevs, i);
|
||||
bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK);
|
||||
bool usesVFIO = (virPCIDeviceGetStubDriver(pci) == VIR_PCI_STUB_DRIVER_VFIO);
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, dom_name, usesVFIO };
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = {mgr, drv_name, dom_name, usesVFIO};
|
||||
int hdrType = -1;
|
||||
|
||||
if (virPCIGetHeaderType(pci, &hdrType) < 0)
|
||||
@ -1995,7 +1996,7 @@ int
|
||||
virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,
|
||||
virPCIDevicePtr pci)
|
||||
{
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = {mgr, NULL, NULL, false};
|
||||
int ret = -1;
|
||||
|
||||
virObjectLock(mgr->activePCIHostdevs);
|
||||
@ -2021,7 +2022,7 @@ int
|
||||
virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
|
||||
virPCIDevicePtr pci)
|
||||
{
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
|
||||
struct virHostdevIsPCINodeDeviceUsedData data = {mgr, NULL, NULL, false};
|
||||
int ret = -1;
|
||||
|
||||
virObjectLock(mgr->activePCIHostdevs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user