[Libvirt-cim] [PATCH] Set PoolID for CIM_DiskResourceAllocationSettingData

Sharad Mishra snmishra at us.ibm.com
Mon Jul 18 18:12:01 UTC 2011


# HG changeset patch
# User Sharad Mishra <snmishra at us.ibm.com>
# Date 1311012637 25200
# Node ID d1f131ad4cf75263d8178ebb89ad9dada3997280
# Parent  e8c1cdd5c9cbe887286ef169d8ff525cc9035485
Set PoolID for CIM_DiskResourceAllocationSettingData.

PoolID wasn't getting set for DiskResourceAllocationSettingData. PoolID
for DiskResourceAllocationSettingData is set by appending "DiskPool"
to the Storage Pool name.

Signed-off-by: Sharad Mishra <snmishra at us.ibm.com>

diff -r e8c1cdd5c9cb -r d1f131ad4cf7 src/Virt_RASD.c
--- a/src/Virt_RASD.c	Sun Jul 17 12:37:31 2011 -0700
+++ b/src/Virt_RASD.c	Mon Jul 18 11:10:37 2011 -0700
@@ -234,6 +234,7 @@
         uint64_t cap = 0;
         uint16_t type;
         CMPIStatus s = {CMPI_RC_OK, NULL};
+        char *poolid = NULL;
 
         get_vol_size(broker, ref, dev->dev.disk.source, &cap);
 
@@ -253,6 +254,55 @@
                       (CMPIValue *)dev->dev.disk.source,
                       CMPI_chars);
 
+        virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+        if (conn == NULL) {
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_NOT_FOUND,
+                                conn,
+                                "Could not get connection to hypervisor");
+                goto cont;
+        }
+
+        virStorageVolPtr vol = virStorageVolLookupByPath(conn, 
+                                                         dev->dev.disk.source);
+        if (vol == NULL) {
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_NOT_FOUND,
+                                conn,
+                                "Failed to get StorageVolPtr");
+                goto cont;
+        }
+
+        virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol);
+        if (pool == NULL) {
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_NOT_FOUND,
+                                conn,
+                                "Failed to get StoragePoolPtr");
+                goto cont;
+        }
+
+        char *pool_name = virStoragePoolGetName(pool);
+        if (pool_name == NULL) {
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_NOT_FOUND,
+                                conn,
+                                "Failed to get Pool name for volume");
+                goto cont;
+        }
+
+        int ret = asprintf(&poolid, "DiskPool/%s", pool_name);
+
+        if (ret == -1) {
+               CU_DEBUG("Failed to get disk poolid");
+               goto cont;
+        }
+
+        CMSetProperty(inst,
+                      "PoolID",
+                      (CMPIValue *)poolid,
+                      CMPI_chars);
+ cont:
         CMSetProperty(inst,
                       "BusType",
                       (CMPIValue *)dev->dev.disk.bus_type,




More information about the Libvirt-cim mailing list