[libvirt] [PATCH v2 3/3] util: Drop virPCIGetAddrString()

Andrea Bolognani abologna at redhat.com
Wed Sep 5 08:09:26 UTC 2018


There's a single user for it which takes an existing
virPCIDeviceAddress, passes its various bits to the
function which in turn constructs a virPCIDevice and
then copies the string representation for the caller
to use: we can use virPCIDeviceAddressAsString()
instead and avoid creating the virPCIDevice in the
first place. Since the function ends up having no
users after the change, we can just drop it.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/util/virnetdev.c |  6 +-----
 src/util/virpci.c    | 16 ----------------
 src/util/virpci.h    |  7 -------
 3 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 8eac419725..9cc9d18155 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1305,11 +1305,7 @@ virNetDevGetVirtualFunctions(const char *pfname,
         goto cleanup;
 
     for (i = 0; i < *n_vfname; i++) {
-        if (virPCIGetAddrString((*virt_fns)[i]->domain,
-                                (*virt_fns)[i]->bus,
-                                (*virt_fns)[i]->slot,
-                                (*virt_fns)[i]->function,
-                                &pciConfigAddr) < 0) {
+        if (!(pciConfigAddr = virPCIDeviceAddressAsString((*virt_fns)[i]))) {
             virReportSystemError(ENOSYS, "%s",
                                  _("Failed to get PCI Config Address String"));
             goto cleanup;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index d82da710ee..1730d888f7 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1668,22 +1668,6 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name)
     return id_str;
 }
 
-int
-virPCIGetAddrString(unsigned int domain,
-                    unsigned int bus,
-                    unsigned int slot,
-                    unsigned int function,
-                    char **pciConfigAddr)
-{
-    VIR_AUTOPTR(virPCIDevice) dev = NULL;
-
-    dev = virPCIDeviceNew(domain, bus, slot, function);
-    if (!dev || VIR_STRDUP(*pciConfigAddr, dev->name) < 0)
-        return -1;
-
-    return 0;
-}
-
 char *
 virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
 {
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 271a753be2..b4f72f8f06 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -218,13 +218,6 @@ int virPCIGetSysfsFile(char *virPCIDeviceName,
                              char **pci_sysfs_device_link)
     ATTRIBUTE_RETURN_CHECK;
 
-int virPCIGetAddrString(unsigned int domain,
-                        unsigned int bus,
-                        unsigned int slot,
-                        unsigned int function,
-                        char **pciConfigAddr)
-    ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
-
 char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
       ATTRIBUTE_NONNULL(1);
 
-- 
2.17.1




More information about the libvir-list mailing list