We will support multi function PCI device. So we should reserve all functions in the slot if we want to reserve a slot. --- src/qemu/qemu_command.c | 37 ++++++++++++++++++++++++++++++++++--- src/qemu/qemu_command.h | 4 ++++ 2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4ca6fe3..48834f1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 528031d..4c83182 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -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); -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list