virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
{
- return !!addrs->buses[addr->bus].slots[addr->slot];
+ return !!addrs->buses[addr->bus].slot[addr->slot].functions;
}
bus = &addrs->buses[addr->bus];
if (reserveEntireSlot) {
- if (bus->slots[addr->slot]) {
+ if (bus->slot[addr->slot].functions) {
virReportError(errType,
_("Attempted double use of PCI slot %s "
"(may need \"multifunction='on'\" for "
"device on function 0)"), addrStr);
goto cleanup;
}
- bus->slots[addr->slot] = 0xFF; /* reserve all functions of slot */
+ bus->slot[addr->slot].functions = 0xFF; /* reserve all functions of slot */
VIR_DEBUG("Reserving PCI slot %s (multifunction='off')", addrStr);
} else {
- if (bus->slots[addr->slot] & (1 << addr->function)) {
+ if (bus->slot[addr->slot].functions & (1 << addr->function)) {
if (addr->function == 0) {
virReportError(errType,
_("Attempted double use of PCI Address %s"),
}
goto cleanup;
}
- bus->slots[addr->slot] |= (1 << addr->function);
+ bus->slot[addr->slot].functions |= (1 << addr->function);
VIR_DEBUG("Reserving PCI address %s", addrStr);
}
virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virPCIDeviceAddressPtr addr)
{
- addrs->buses[addr->bus].slots[addr->slot] &= ~(1 << addr->function);
+ addrs->buses[addr->bus].slot[addr->slot].functions &= ~(1 << addr->function);
return 0;
}
if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, false))
goto cleanup;
- addrs->buses[addr->bus].slots[addr->slot] = 0;
+ addrs->buses[addr->bus].slot[addr->slot].functions = 0;
ret = 0;
cleanup:
VIR_FREE(addrStr);
virDomainPCIConnectFlags
virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model);
+typedef struct {
+ /* each function is represented by one bit, set if that function is
+ * in use by a device, or clear if it isn't.
+ */
+ uint8_t functions;
+} virDomainPCIAddressSlot;
+
typedef struct {
virDomainControllerModelPCI model;
/* flags and min/max can be computed from model, but
/* Each bit in a slot represents one function on that slot. If the
* bit is set, that function is in use by a device.
*/
- uint8_t slots[VIR_PCI_ADDRESS_SLOT_LAST + 1];
+ virDomainPCIAddressSlot slot[VIR_PCI_ADDRESS_SLOT_LAST + 1];
} virDomainPCIAddressBus;
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;