[PATCH v2 03/21] virhostdev: Introduce virHostdevPCIDevicesBelongToSameSlot

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

 



From: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virhostdev.c    | 29 +++++++++++++++++++++++++++++
 src/util/virhostdev.h    |  2 ++
 3 files changed, 32 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 962963a3ff..702cd958b1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2166,6 +2166,7 @@ virHostdevIsPCIMultifunctionDevice;
 virHostdevIsSCSIDevice;
 virHostdevIsVFIODevice;
 virHostdevManagerGetDefault;
+virHostdevPCIDevicesBelongToSameSlot;
 virHostdevPCINodeDeviceDetach;
 virHostdevPCINodeDeviceReAttach;
 virHostdevPCINodeDeviceReset;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index f0526d97d0..d870ca6c49 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -312,6 +312,35 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev)
 }
 
 
+bool
+virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1,
+                                     virDomainHostdevDefPtr dev2)
+{
+    virPCIDeviceAddressPtr devAddr1 = NULL, devAddr2 = NULL;
+
+    if (!dev1 || !dev2)
+        return false;
+
+    devAddr1 = &dev1->source.subsys.u.pci.addr;
+    devAddr2 = &dev2->source.subsys.u.pci.addr;
+    if ((devAddr1->domain != devAddr2->domain) ||
+        (devAddr1->bus != devAddr2->bus) ||
+        (devAddr1->slot != devAddr2->slot) ||
+        (virPCIDeviceAddressEqual(devAddr1, devAddr2))) {
+        return false;
+    }
+
+    /* The Virtual Functions have multifunction false even though they have same
+     * domain:bus:slot as the Physical function. They are to be treated
+     * like non-multifunction devices
+     */
+    if (virHostdevIsVirtualFunction(dev1) || virHostdevIsVirtualFunction(dev2))
+        return false;
+
+    return true;
+}
+
+
 static int
 virHostdevNetDevice(virDomainHostdevDefPtr hostdev,
                     int pfNetDevIdx,
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index 80aea577ed..d6dfb0b388 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -214,6 +214,8 @@ int virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
 int virHostdevPCINodeDeviceReset(virHostdevManagerPtr mgr,
                                  virPCIDevicePtr pci)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+bool virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1,
+                                          virDomainHostdevDefPtr dev2);
 
 int
 virHostdevPrepareOneNVMeDevice(virHostdevManagerPtr hostdev_mgr,
-- 
2.24.1






[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