conf: start search for next unused PCI address at same slot as previous find

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).
This commit is contained in:
Laine Stump 2016-10-21 13:05:33 -04:00
parent 99bf66f3fa
commit 66e0b08d34

View File

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