On Mon, 2016-12-19 at 10:23 -0500, Laine Stump wrote:
If a PCI device has VIR_PCI_CONNECT_AGGREGATE_SLOT set in its
pciConnectFlags, then during address assignment we allow multiple
instances of this type of device to be auto-assigned to multiple
functions on the same device. A slot is used for aggregating multiple
devices only if the first device assigned to that slot had
VIR_PCI_CONNECT_AGGREGATE_SLOT set. but any device types that have
AGGREGATE_SLOT set might be mix/matched on the same slot.
[...]
@@ -717,6 +729,33 @@
virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus,
break;
}
+ if (flags & VIR_PCI_CONNECT_AGGREGATE_SLOT &&
+ bus->slot[searchAddr->slot].aggregate) {
+ /* slot and device are okay with aggregating devices */
+ if ((bus->slot[searchAddr->slot].functions &
+ (1 << searchAddr->function)) == 0) {
+ *found = true;
+ break;
+ }
+
+ /* also check for *any* unused function if caller
+ * sent function = -1
+ */
+ if (function == -1) {
+ while (searchAddr->function < 8) {
We know this works because virDomainPCIAddressGetNextSlot()
will set 'searchAddr->function = 0' when 'function == -1',
but I'd rather see...
+ if
((bus->slot[searchAddr->slot].functions &
+ (1 << searchAddr->function)) == 0) {
+ *found = true;
+ break; /* out of inner while */
+ }
+ searchAddr->function++;
+ }
+ if (*found)
+ break; /* out of outer while */
+ searchAddr->function = 0; /* reset for next try */
... this line moved right before the while() loop to get
rid of that dependency entirely.
ACK with that changed.
--
Andrea Bolognani / Red Hat / Virtualization