mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-28 11:21:44 +03:00
Reimplement qemuDomainPCIAddressReserveSlot(): reserve all functions in the slot
We will support multi function PCI device. So we should reserve all functions in the slot if we want to reserve a slot.
This commit is contained in:
parent
d8f24f75a8
commit
38912f3107
@ -667,6 +667,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virBitmapPtr qemuCaps)
|
||||
|
||||
|
||||
#define QEMU_PCI_ADDRESS_LAST_SLOT 31
|
||||
#define QEMU_PCI_ADDRESS_LAST_FUNCTION 8
|
||||
struct _qemuDomainPCIAddressSet {
|
||||
virHashTablePtr used;
|
||||
int nextslot;
|
||||
@ -810,19 +811,37 @@ int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot)
|
||||
int qemuDomainPCIAddressReserveFunction(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot, int function)
|
||||
{
|
||||
virDomainDeviceInfo dev;
|
||||
|
||||
dev.addr.pci.domain = 0;
|
||||
dev.addr.pci.bus = 0;
|
||||
dev.addr.pci.slot = slot;
|
||||
dev.addr.pci.function = 0;
|
||||
dev.addr.pci.function = function;
|
||||
|
||||
return qemuDomainPCIAddressReserveAddr(addrs, &dev);
|
||||
}
|
||||
|
||||
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot)
|
||||
{
|
||||
int function;
|
||||
|
||||
for (function = 0; function <= QEMU_PCI_ADDRESS_LAST_FUNCTION; function++) {
|
||||
if (qemuDomainPCIAddressReserveFunction(addrs, slot, function) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
for (function--; function >= 0; function--) {
|
||||
qemuDomainPCIAddressReleaseFunction(addrs, slot, function);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
virDomainDeviceInfoPtr dev)
|
||||
@ -853,6 +872,18 @@ int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qemuDomainPCIAddressReleaseFunction(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot, int function)
|
||||
{
|
||||
virDomainDeviceInfo dev;
|
||||
|
||||
dev.addr.pci.domain = 0;
|
||||
dev.addr.pci.bus = 0;
|
||||
dev.addr.pci.slot = slot;
|
||||
dev.addr.pci.function = function;
|
||||
|
||||
return qemuDomainPCIAddressReleaseAddr(addrs, &dev);
|
||||
}
|
||||
|
||||
void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs)
|
||||
{
|
||||
|
@ -146,6 +146,8 @@ virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
|
||||
|
||||
int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
|
||||
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
|
||||
int qemuDomainPCIAddressReserveFunction(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot, int function);
|
||||
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot);
|
||||
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
@ -156,6 +158,8 @@ int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
virDomainDeviceInfoPtr dev);
|
||||
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||
virDomainDeviceInfoPtr dev);
|
||||
int qemuDomainPCIAddressReleaseFunction(qemuDomainPCIAddressSetPtr addrs,
|
||||
int slot, int function);
|
||||
|
||||
void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs);
|
||||
int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs);
|
||||
|
Loading…
Reference in New Issue
Block a user