From a72ab39ba75702676af64af30d9412f5d7730cd9 Mon Sep 17 00:00:00 2001 From: Viktor Mihajlovski Date: Mon, 14 Oct 2013 17:29:42 +0200 Subject: [PATCH 27/60] RASD: Support for device address properties This change allows to enumerate KVM disk and network RASDs containing device addresses. A new function set_rasd_device_address fills the CIM instance properties from a device_address structure. Signed-off-by: Viktor Mihajlovski Signed-off-by: John Ferlan --- src/Virt_RASD.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index e28d4e6..df1e921 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -289,6 +289,67 @@ static bool get_vol_size(const CMPIBroker *broker, } #endif +static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct device_address *addr, + CMPIInstance *inst) +{ + int i; + CMPIArray *arr_key; + CMPIArray *arr_value; + CMPIString *string; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + arr_key = CMNewArray(broker, + addr->ct, + CMPI_string, + &s); + if (s.rc != CMPI_RC_OK) + goto out; + + arr_value = CMNewArray(broker, + addr->ct, + CMPI_string, + &s); + if (s.rc != CMPI_RC_OK) + goto out; + + for (i = 0; i < addr->ct; i++) { + string = CMNewString(broker, + addr->key[i], + &s); + if (s.rc != CMPI_RC_OK) + goto out; + + CMSetArrayElementAt(arr_key, + i, + (CMPIValue *)&string, + CMPI_string); + + string = CMNewString(broker, + addr->value[i], + &s); + if (s.rc != CMPI_RC_OK) + goto out; + + CMSetArrayElementAt(arr_value, + i, + (CMPIValue *)&string, + CMPI_string); + } + + CMSetProperty(inst, "AddressProperties", + (CMPIValue *)&arr_key, + CMPI_stringA); + + CMSetProperty(inst, "AddressValues", + (CMPIValue *)&arr_value, + CMPI_stringA); + + out: + return s; +} + static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, const CMPIObjectPath *ref, const struct virt_device *dev, @@ -427,6 +488,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, (CMPIValue *)&(dev->dev.disk.shareable), CMPI_boolean); + if (dev->dev.disk.address.ct > 0) + set_rasd_device_address(broker, + ref, + &dev->dev.disk.address, + inst); + virStoragePoolFree(pool); virStorageVolFree(vol); virConnectClose(conn); @@ -590,6 +657,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, (CMPIValue *)dev->dev.net.poolid, CMPI_chars); + if (dev->dev.net.address.ct > 0) + set_rasd_device_address(broker, + ref, + &dev->dev.net.address, + inst); + #if LIBVIR_VERSION_NUMBER < 9000 out: #endif -- 2.1.0