]> xenbits.xensource.com Git - libvirt.git/commitdiff
virpci: Implement virPCIDeviceGetAddress function
authorShivaprasad G Bhat <shivaprasadbhat@gmail.com>
Wed, 14 Jan 2015 11:02:40 +0000 (06:02 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Jan 2015 17:01:06 +0000 (18:01 +0100)
Basically a getter function which is implemented for accessing the
address fields in virPCIDevice.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virpci.c
src/util/virpci.h

index cd78212a00218e3eb2810003d26e9df80d949016..512e8399eb15048da825537ad65a15291b937068 100644 (file)
@@ -1655,6 +1655,32 @@ virPCIDeviceFree(virPCIDevicePtr dev)
     VIR_FREE(dev);
 }
 
+/**
+ * virPCIDeviceGetAddress:
+ * @dev: device to get address from
+ *
+ * Take a PCI device on input and return its PCI address. The
+ * caller must free the returned value when no longer needed.
+ *
+ * Returns NULL on failure, the device address on success.
+ */
+virPCIDeviceAddressPtr
+virPCIDeviceGetAddress(virPCIDevicePtr dev)
+{
+
+    virPCIDeviceAddressPtr pciAddrPtr;
+
+    if (!dev || (VIR_ALLOC(pciAddrPtr) < 0))
+        return NULL;
+
+    pciAddrPtr->domain = dev->domain;
+    pciAddrPtr->bus = dev->bus;
+    pciAddrPtr->slot = dev->slot;
+    pciAddrPtr->function = dev->function;
+
+    return pciAddrPtr;
+}
+
 const char *
 virPCIDeviceGetName(virPCIDevicePtr dev)
 {
index 1ce9821e003ad2f6bb5315e1a0e171df5855c582..64b9e96040ebbfb9a994c8bc76cebfe81bde56ef 100644 (file)
@@ -94,6 +94,7 @@ int virPCIDeviceSetStubDriver(virPCIDevicePtr dev,
                               const char *driver)
     ATTRIBUTE_NONNULL(2);
 const char *virPCIDeviceGetStubDriver(virPCIDevicePtr dev);
+virPCIDeviceAddressPtr virPCIDeviceGetAddress(virPCIDevicePtr dev);
 int virPCIDeviceSetUsedBy(virPCIDevice *dev,
                           const char *drv_name,
                           const char *dom_name);