]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: start search for next unused PCI address at same slot as previous find
authorLaine Stump <laine@laine.org>
Fri, 21 Oct 2016 17:05:33 +0000 (13:05 -0400)
committerLaine Stump <laine@laine.org>
Wed, 11 Jan 2017 09:39:08 +0000 (04:39 -0500)
There is a very slight time advantage to beginning the search for the
next unused PCI address at the slot *after* the previous find (which
is now used), but if we do that, we will miss allocating the other
functions of the same slot (when we implement a
VIR_PCI_CONNECT_AGGREGATE_SLOT flag to support that).

src/conf/domain_addr.c

index 5feed058788f71cb645e6c796eb0f700c3571b81..4d14ac495328deef78594e0965c4044a897fc18b 100644 (file)
@@ -748,18 +748,14 @@ virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs,
     }
 
     /* ...unless this search is for the exact same type of device as
-     * last time, then continue the search from the next slot after
-     * the previous match (the "next slot" may possibly be the first
-     * slot of the next bus).
+     * last time, then continue the search from the slot where we
+     * found the previous match (it's possible there will still be a
+     * function available on that slot).
      */
-    if (flags == addrs->lastFlags) {
+    if (flags == addrs->lastFlags)
         a = addrs->lastaddr;
-        if (++a.slot > addrs->buses[a.bus].maxSlot &&
-            ++a.bus < addrs->nbuses)
-            a.slot = addrs->buses[a.bus].minSlot;
-    } else {
+    else
         a.slot = addrs->buses[0].minSlot;
-    }
 
     /* if the caller asks for "any function", give them function 0 */
     if (function == -1)