[PATCH] Set PoolID for CIM_DiskResourceAllocationSettingData

# HG changeset patch # User Sharad Mishra <snmishra@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@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,

On 07/18/2011 02:12 PM, Sharad Mishra wrote:
# HG changeset patch # User Sharad Mishra<snmishra@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@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);
cc1: warnings being treated as errors Virt_RASD.c: In function ‘set_disk_rasd_params’: Virt_RASD.c:285: error: initialization discards qualifiers from pointer target type According to libvirt docs: const char * virStoragePoolGetName (virStoragePoolPtr 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,
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 07/20/2011 06:48:50 AM:
Chip Vincent <cvincent@linux.vnet.ibm.com> Sent by: libvirt-cim-bounces@redhat.com
07/20/11 06:48 AM
Please respond to cvincent@linux.vnet.ibm.com; Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com>
To
libvirt-cim@redhat.com
cc
Subject
Re: [Libvirt-cim] [PATCH] Set PoolID for CIM_DiskResourceAllocationSettingData
On 07/18/2011 02:12 PM, Sharad Mishra wrote:
# HG changeset patch # User Sharad Mishra<snmishra@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@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);
cc1: warnings being treated as errors Virt_RASD.c: In function ‘set_disk_rasd_params’: Virt_RASD.c:285: error: initialization discards qualifiers from pointer target type
According to libvirt docs: const char * virStoragePoolGetName (virStoragePoolPtr pool)
that's right. donno why it did not complain for me. I compile with warning enabled too. Will do another patch and resend. -Sharad
+ 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,
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Chip Vincent
-
Sharad Mishra