]> xenbits.xensource.com Git - libvirt.git/commitdiff
hostdev: Remove virHostdevGetActivePCIHostDeviceList()
authorAndrea Bolognani <abologna@redhat.com>
Wed, 24 Feb 2016 12:37:44 +0000 (13:37 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 15 Mar 2016 09:33:17 +0000 (10:33 +0100)
virHostdevGetPCIHostDeviceList() is similar but does not filter out
devices that are not in the active list; that said, we are looking
up the device in the active list just a few lines after anyway, so
we might as well just keep a single function around.

This also helps stress the fact the objects contained in pcidevs are
only for looking up the actual devices, which is something later
commits will make even more explicit.

src/util/virhostdev.c

index 188daf2eda0b16e91cd4de41dbc5a7379c48d5f2..028b89977fce6aad7d1ae6cac7b17bca99d0300f 100644 (file)
@@ -245,49 +245,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
 }
 
 
-/*
- * virHostdevGetActivePCIHostDeviceList - make a new list with a *copy* of
- *   every virPCIDevice object that is found on the activePCIHostdevs
- *   list *and* is in the hostdev list for this domain.
- *
- * Return the new list, or NULL if there was a failure.
- *
- * Pre-condition: activePCIHostdevs is locked
- */
-static virPCIDeviceListPtr
-virHostdevGetActivePCIHostDeviceList(virHostdevManagerPtr mgr,
-                                     virDomainHostdevDefPtr *hostdevs,
-                                     int nhostdevs)
-{
-    virPCIDeviceListPtr list;
-    size_t i;
-
-    if (!(list = virPCIDeviceListNew()))
-        return NULL;
-
-    for (i = 0; i < nhostdevs; i++) {
-        virDomainHostdevDefPtr hostdev = hostdevs[i];
-        virDevicePCIAddressPtr addr;
-        virPCIDevicePtr activeDev;
-
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
-            continue;
-        if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
-            continue;
-
-        addr = &hostdev->source.subsys.u.pci.addr;
-        activeDev = virPCIDeviceListFindByIDs(mgr->activePCIHostdevs,
-                                              addr->domain, addr->bus,
-                                              addr->slot, addr->function);
-        if (activeDev && virPCIDeviceListAddCopy(list, activeDev) < 0) {
-            virObjectUnref(list);
-            return NULL;
-        }
-    }
-
-    return list;
-}
-
 static int
 virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev,
                        char **sysfs_path)
@@ -801,9 +758,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
     virObjectLock(mgr->activePCIHostdevs);
     virObjectLock(mgr->inactivePCIHostdevs);
 
-    if (!(pcidevs = virHostdevGetActivePCIHostDeviceList(mgr,
-                                                         hostdevs,
-                                                         nhostdevs))) {
+    if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
         virErrorPtr err = virGetLastError();
         VIR_ERROR(_("Failed to allocate PCI device list: %s"),
                   err ? err->message : _("unknown error"));
@@ -833,6 +788,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
                 virPCIDeviceListDel(pcidevs, dev);
                 continue;
             }
+        } else {
+            virPCIDeviceListDel(pcidevs, dev);
+            continue;
         }
 
         VIR_DEBUG("Removing PCI device %s from active list",