[PATCH 18/20] virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListSteal()

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Jan 4 12:54:42 UTC 2021


Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/hypervisor/virhostdev.c | 8 +++++---
 src/util/virpci.c           | 6 +++---
 src/util/virpci.h           | 2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index e7ef615f60..4539c55e09 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -846,7 +846,7 @@ virHostdevPreparePCIDevicesImpl(virHostdevManagerPtr mgr,
 
         VIR_DEBUG("Removing PCI device %s from inactive list",
                   virPCIDeviceGetName(pci));
-        actual = virPCIDeviceListSteal(mgr->inactivePCIHostdevs, pci);
+        actual = virPCIDeviceListSteal(mgr->inactivePCIHostdevs, virPCIDeviceGetAddress(pci));
 
         VIR_DEBUG("Adding PCI device %s to active list",
                   virPCIDeviceGetName(pci));
@@ -918,7 +918,8 @@ virHostdevPreparePCIDevicesImpl(virHostdevManagerPtr mgr,
 
         VIR_DEBUG("Removing PCI device %s from active list",
                   virPCIDeviceGetName(pci));
-        if (!(actual = virPCIDeviceListSteal(mgr->activePCIHostdevs, pci)))
+        if (!(actual = virPCIDeviceListSteal(mgr->activePCIHostdevs,
+                                             virPCIDeviceGetAddress(pci))))
             continue;
 
         VIR_DEBUG("Adding PCI device %s to inactive list",
@@ -1022,7 +1023,8 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
 
         VIR_DEBUG("Removing PCI device %s from active list",
                   virPCIDeviceGetName(pci));
-        actual = virPCIDeviceListSteal(mgr->activePCIHostdevs, pci);
+        actual = virPCIDeviceListSteal(mgr->activePCIHostdevs,
+                                       virPCIDeviceGetAddress(pci));
 
         VIR_DEBUG("Adding PCI device %s to inactive list",
                   virPCIDeviceGetName(pci));
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 938ffeaaed..8973c7c754 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1743,16 +1743,16 @@ virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
 
 virPCIDevicePtr
 virPCIDeviceListSteal(virPCIDeviceListPtr list,
-                      virPCIDevicePtr dev)
+                      virPCIDeviceAddressPtr devAddr)
 {
-    return virPCIDeviceListStealIndex(list, virPCIDeviceListFindIndex(list, &dev->address));
+    return virPCIDeviceListStealIndex(list, virPCIDeviceListFindIndex(list, devAddr));
 }
 
 void
 virPCIDeviceListDel(virPCIDeviceListPtr list,
                     virPCIDevicePtr dev)
 {
-    virPCIDeviceFree(virPCIDeviceListSteal(list, dev));
+    virPCIDeviceFree(virPCIDeviceListSteal(list, &dev->address));
 }
 
 int
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 628a293972..e3458a75fa 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -161,7 +161,7 @@ virPCIDevicePtr virPCIDeviceListGet(virPCIDeviceListPtr list,
                                     int idx);
 size_t virPCIDeviceListCount(virPCIDeviceListPtr list);
 virPCIDevicePtr virPCIDeviceListSteal(virPCIDeviceListPtr list,
-                                      virPCIDevicePtr dev);
+                                      virPCIDeviceAddressPtr devAddr);
 virPCIDevicePtr virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
                                            int idx);
 void virPCIDeviceListDel(virPCIDeviceListPtr list,
-- 
2.26.2




More information about the libvir-list mailing list