Re: [PATCH 14/18] virhostdev: Check driver name too in virHostdevIsPCINodeDeviceUsed()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>

On 8/14/19 8:57 AM, Michal Privoznik wrote:
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@xxxxxxxxxx>
---
  src/util/virhostdev.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 75e44b5227..cb69582c21 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -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);

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux