]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: eliminate virDomainPCIAddressReleaseSlot() in favor of ...Addr()
authorLaine Stump <laine@laine.org>
Mon, 24 Oct 2016 15:25:53 +0000 (11:25 -0400)
committerLaine Stump <laine@laine.org>
Wed, 11 Jan 2017 10:00:34 +0000 (05:00 -0500)
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
src/conf/domain_addr.h
src/libvirt_private.syms
src/qemu/qemu_domain_address.c

index 500abb13638003f4fdc6cea550541f45d48b4b58..555da5973ef59dc048c9244b6d61b779ab8517ee 100644 (file)
@@ -646,31 +646,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)
 {
index f4499b316bc47fed075044f864ae28c9b60a6af1..632f0c0511c261105d9ba341d4278b2c093b832e 100644 (file)
@@ -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,
index d3d0e1e676559e1b036ed28b21fe52d41a258487..9c74d35c4533d58f0538e97a4599410489f767d3 100644 (file)
@@ -99,7 +99,7 @@ virDomainPCIAddressAsString;
 virDomainPCIAddressBusSetModel;
 virDomainPCIAddressEnsureAddr;
 virDomainPCIAddressFlagsCompatible;
-virDomainPCIAddressReleaseSlot;
+virDomainPCIAddressReleaseAddr;
 virDomainPCIAddressReserveAddr;
 virDomainPCIAddressReserveNextAddr;
 virDomainPCIAddressSetAllMulti;
index abb37b2bc13fee391e0cb9a18e31832abbedf520..9cd1e9e0f44373cba05804e78acda30abf28b6e2 100644 (file)
@@ -2545,7 +2545,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));