mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
conf: use struct instead of int for each slot in virDomainPCIAddressBus
When keeping track of which functions of which slots are allocated, we will need to have more information than just the current bitmap with a bit for each function that is currently stored for each slot in a virDomainPCIAddressBus. To prepare for adding more per-slot info, this patch changes "uint8_t slots" into "virDomainPCIAddressSlot slot", which currently has a single member named "functions" that serves the same purpose previously served directly by "slots".
This commit is contained in:
parent
a30b08b717
commit
9838cad9cd
@ -522,7 +522,7 @@ bool
|
|||||||
virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
|
virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs,
|
||||||
virPCIDeviceAddressPtr addr)
|
virPCIDeviceAddressPtr addr)
|
||||||
{
|
{
|
||||||
return !!addrs->buses[addr->bus].slots[addr->slot];
|
return !!addrs->buses[addr->bus].slot[addr->slot].functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -563,17 +563,17 @@ virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
|
|||||||
bus = &addrs->buses[addr->bus];
|
bus = &addrs->buses[addr->bus];
|
||||||
|
|
||||||
if (reserveEntireSlot) {
|
if (reserveEntireSlot) {
|
||||||
if (bus->slots[addr->slot]) {
|
if (bus->slot[addr->slot].functions) {
|
||||||
virReportError(errType,
|
virReportError(errType,
|
||||||
_("Attempted double use of PCI slot %s "
|
_("Attempted double use of PCI slot %s "
|
||||||
"(may need \"multifunction='on'\" for "
|
"(may need \"multifunction='on'\" for "
|
||||||
"device on function 0)"), addrStr);
|
"device on function 0)"), addrStr);
|
||||||
goto cleanup;
|
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);
|
VIR_DEBUG("Reserving PCI slot %s (multifunction='off')", addrStr);
|
||||||
} else {
|
} else {
|
||||||
if (bus->slots[addr->slot] & (1 << addr->function)) {
|
if (bus->slot[addr->slot].functions & (1 << addr->function)) {
|
||||||
if (addr->function == 0) {
|
if (addr->function == 0) {
|
||||||
virReportError(errType,
|
virReportError(errType,
|
||||||
_("Attempted double use of PCI Address %s"),
|
_("Attempted double use of PCI Address %s"),
|
||||||
@ -586,7 +586,7 @@ virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
|
|||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
bus->slots[addr->slot] |= (1 << addr->function);
|
bus->slot[addr->slot].functions |= (1 << addr->function);
|
||||||
VIR_DEBUG("Reserving PCI address %s", addrStr);
|
VIR_DEBUG("Reserving PCI address %s", addrStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,7 +653,7 @@ int
|
|||||||
virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
|
virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
|
||||||
virPCIDeviceAddressPtr addr)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs,
|
|||||||
if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, false))
|
if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, false))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
addrs->buses[addr->bus].slots[addr->slot] = 0;
|
addrs->buses[addr->bus].slot[addr->slot].functions = 0;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(addrStr);
|
VIR_FREE(addrStr);
|
||||||
|
@ -70,6 +70,13 @@ typedef enum {
|
|||||||
virDomainPCIConnectFlags
|
virDomainPCIConnectFlags
|
||||||
virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model);
|
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 {
|
typedef struct {
|
||||||
virDomainControllerModelPCI model;
|
virDomainControllerModelPCI model;
|
||||||
/* flags and min/max can be computed from model, but
|
/* flags and min/max can be computed from model, but
|
||||||
@ -80,7 +87,7 @@ typedef struct {
|
|||||||
/* Each bit in a slot represents one function on that slot. If the
|
/* Each bit in a slot represents one function on that slot. If the
|
||||||
* bit is set, that function is in use by a device.
|
* 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;
|
} virDomainPCIAddressBus;
|
||||||
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
|
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
|
||||||
|
|
||||||
|
@ -1504,7 +1504,7 @@ qemuDomainPCIBusFullyReserved(virDomainPCIAddressBusPtr bus)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = bus->minSlot; i <= bus->maxSlot; i++)
|
for (i = bus->minSlot; i <= bus->maxSlot; i++)
|
||||||
if (!bus->slots[i])
|
if (!bus->slot[i].functions)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user