Surprisingly there was a virDomainPCIAddressReleaseAddr() function already, but it was completely unused. Since we don't reserve entire slots at once any more, there is no need to release entire slots either, so we just replace the single call to virDomainPCIAddressReleaseSlot() with a call to virDomainPCIAddressReleaseAddr() and remove the now unused function. The keen observer may be concerned that ...Addr() doesn't call virDomainPCIAddressValidate(), as ...Slot() did. But really the validation was pointless anyway - if the device hadn't been suitable to be connected at that address, it would have failed validation before every being reserved in the first place, so by definition it will pass validation when it is being unplugged. (And anyway, even if something "bad" happened and we managed to have a device incorrectly at the given address, we would still want to be able to free it up for use by a device that *did* validate properly). --- src/conf/domain_addr.c | 25 ------------------------- src/conf/domain_addr.h | 4 ---- src/libvirt_private.syms | 2 +- src/qemu/qemu_domain_address.c | 2 +- 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 345c274..ebcc494 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -647,31 +647,6 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, return 0; } -int -virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs, - virPCIDeviceAddressPtr addr) -{ - /* permit any kind of connection type in validation, since we - * already had it, and are giving it back. - */ - virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPES_MASK; - int ret = -1; - char *addrStr = NULL; - - if (!(addrStr = virDomainPCIAddressAsString(addr))) - goto cleanup; - - if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, true)) - goto cleanup; - - addrs->buses[addr->bus].slot[addr->slot].functions = 0; - ret = 0; - cleanup: - VIR_FREE(addrStr); - return ret; -} - - virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses) { diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index dac73fa..ee44c50 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -164,10 +164,6 @@ int virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs, - virPCIDeviceAddressPtr addr) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs, virDomainDeviceInfoPtr dev, virDomainPCIConnectFlags flags, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1f54ea4..7607faa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -100,7 +100,7 @@ virDomainPCIAddressBusSetModel; virDomainPCIAddressEnsureAddr; virDomainPCIAddressFlagsCompatible; virDomainPCIAddressIsMulti; -virDomainPCIAddressReleaseSlot; +virDomainPCIAddressReleaseAddr; virDomainPCIAddressReserveAddr; virDomainPCIAddressReserveNextAddr; virDomainPCIAddressSetAlloc; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e6bba8a..89bb794 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2495,7 +2495,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, devstr = info->alias; if (virDeviceInfoPCIAddressPresent(info) && - virDomainPCIAddressReleaseSlot(priv->pciaddrs, + virDomainPCIAddressReleaseAddr(priv->pciaddrs, &info->addr.pci) < 0) VIR_WARN("Unable to release PCI address on %s", NULLSTR(devstr)); -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list