On 14.01.2015 12:02, Shivaprasad G Bhat wrote:
Basically a getter function which is implemented for accessing the
address fields in virPCIDevice.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/util/virpci.c | 16 ++++++++++++++++
src/util/virpci.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index cd78212..831a5d8 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1655,6 +1655,22 @@ virPCIDeviceFree(virPCIDevicePtr dev)
VIR_FREE(dev);
}
I'm adding a comment here to note explicitly that caller must free the
returned value.
+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)
{
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 1ce9821..64b9e96 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -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);
ACK
Michal