mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
conf: eliminate virDomainPCIAddressReleaseSlot() in favor of ...Addr()
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).
This commit is contained in:
parent
6cc2014202
commit
5949b53aec
@ -646,31 +646,6 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
|
|||||||
return 0;
|
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
|
virDomainPCIAddressSetPtr
|
||||||
virDomainPCIAddressSetAlloc(unsigned int nbuses)
|
virDomainPCIAddressSetAlloc(unsigned int nbuses)
|
||||||
{
|
{
|
||||||
|
@ -164,10 +164,6 @@ int virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
|
|||||||
virPCIDeviceAddressPtr addr)
|
virPCIDeviceAddressPtr addr)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
int virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs,
|
|
||||||
virPCIDeviceAddressPtr addr)
|
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
||||||
|
|
||||||
int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
|
int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
|
||||||
virDomainDeviceInfoPtr dev,
|
virDomainDeviceInfoPtr dev,
|
||||||
virDomainPCIConnectFlags flags,
|
virDomainPCIConnectFlags flags,
|
||||||
|
@ -99,7 +99,7 @@ virDomainPCIAddressAsString;
|
|||||||
virDomainPCIAddressBusSetModel;
|
virDomainPCIAddressBusSetModel;
|
||||||
virDomainPCIAddressEnsureAddr;
|
virDomainPCIAddressEnsureAddr;
|
||||||
virDomainPCIAddressFlagsCompatible;
|
virDomainPCIAddressFlagsCompatible;
|
||||||
virDomainPCIAddressReleaseSlot;
|
virDomainPCIAddressReleaseAddr;
|
||||||
virDomainPCIAddressReserveAddr;
|
virDomainPCIAddressReserveAddr;
|
||||||
virDomainPCIAddressReserveNextAddr;
|
virDomainPCIAddressReserveNextAddr;
|
||||||
virDomainPCIAddressSetAllMulti;
|
virDomainPCIAddressSetAllMulti;
|
||||||
|
@ -2545,7 +2545,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
|
|||||||
devstr = info->alias;
|
devstr = info->alias;
|
||||||
|
|
||||||
if (virDeviceInfoPCIAddressPresent(info) &&
|
if (virDeviceInfoPCIAddressPresent(info) &&
|
||||||
virDomainPCIAddressReleaseSlot(priv->pciaddrs,
|
virDomainPCIAddressReleaseAddr(priv->pciaddrs,
|
||||||
&info->addr.pci) < 0)
|
&info->addr.pci) < 0)
|
||||||
VIR_WARN("Unable to release PCI address on %s",
|
VIR_WARN("Unable to release PCI address on %s",
|
||||||
NULLSTR(devstr));
|
NULLSTR(devstr));
|
||||||
|
Loading…
Reference in New Issue
Block a user