[Libvirt-cim] [PATCH 2 of 3] Change xmlgen and RPCC to use DevicePaths

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Jun 19 22:33:23 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1245111972 25200
# Node ID 95e453b65affa4eb77bedfab60c954283e34f0ad
# Parent  dff67e06596528ece42c01eff9e0afbcc2a8a422
Change xmlgen and RPCC to use DevicePaths

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r dff67e065965 -r 95e453b65aff libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Mon Jun 15 17:26:12 2009 -0700
+++ b/libxkutil/xmlgen.c	Mon Jun 15 17:26:12 2009 -0700
@@ -880,19 +880,20 @@
 {
         xmlNodePtr src;
         xmlNodePtr tmp;
+        uint16_t i;
 
         src = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
         if (src == NULL)
                 return XML_ERROR;
 
-        if (pool->device_path != NULL) {
+        for (i = 0; i < pool->device_paths_ct; i++) {
                 tmp = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST NULL);
                 if (tmp == NULL)
                         return XML_ERROR;
 
                 if (xmlNewProp(tmp,
                                BAD_CAST "path",
-                               BAD_CAST pool->device_path) == NULL)
+                               BAD_CAST pool->device_paths[i]) == NULL)
                         return XML_ERROR;
         }
 
diff -r dff67e065965 -r 95e453b65aff src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c	Mon Jun 15 17:26:12 2009 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c	Mon Jun 15 17:26:12 2009 -0700
@@ -142,21 +142,67 @@
 #if VIR_USE_LIBVIRT_STORAGE
 static void init_disk_pool(struct virt_pool *pool)
 {
-        pool->pool_info.disk.device_path = NULL;
+        pool->pool_info.disk.device_paths = NULL;
+        pool->pool_info.disk.device_paths_ct = 0;
         pool->pool_info.disk.path = NULL;
         pool->pool_info.disk.host = NULL;
         pool->pool_info.disk.src_dir = NULL;
 }
 
+static char *get_dev_paths(CMPIInstance *inst, 
+                           char ***path_list,
+                           uint16_t *count)
+{
+        CMPICount i;
+        CMPICount ct;
+        CMPIArray *array;
+        CMPIStatus s;
+        CMPIData elem;
+
+        if (cu_get_array_prop(inst, "DevicePaths", &array) != CMPI_RC_OK)
+                return "Missing `DevicePaths' property";
+
+        ct = CMGetArrayCount(array, &s);
+        if ((s.rc != CMPI_RC_OK) || (ct <= 0))
+                return "Unable to get DevicePaths array count";
+
+        *path_list = calloc(ct, sizeof(char *));
+        if (path_list == NULL)
+                return "Failed to alloc space for device paths";
+
+        *count = ct;
+
+        for (i = 0; i < ct; i++) {
+                const char *str = NULL;
+
+                elem = CMGetArrayElementAt(array, i, NULL);
+                if (CMIsNullValue(elem))
+                        return "Unable to get element from DevicePaths array";
+
+                str = CMGetCharPtr(elem.value.string);
+                if (str == NULL)
+                        return "Unable to get value of DevicePaths element";
+
+                *path_list[i] = strdup(str);
+        }
+
+        return NULL;
+}
+
 static const char *disk_fs_or_disk_pool(CMPIInstance *inst,
                                         struct virt_pool *pool)
 {
-        const char *val = NULL;
+        const char *msg = NULL;
 
-        if (cu_get_str_prop(inst, "DevicePath", &val) != CMPI_RC_OK)
-                return "Missing `DevicePath' property";
+        msg = get_dev_paths(inst, 
+                            &pool->pool_info.disk.device_paths, 
+                            &pool->pool_info.disk.device_paths_ct);
+        
+        if (msg != NULL)
+                return msg;
 
-        pool->pool_info.disk.device_path = strdup(val);
+        if (pool->pool_info.disk.device_paths_ct != 1)
+                return "Specified pool type only takes one device path";
 
         return NULL;
 }
@@ -183,11 +229,17 @@
                                    struct virt_pool *pool)
 {
         const char *val = NULL;
+        const char *msg = NULL;
 
-        if (cu_get_str_prop(inst, "DevicePath", &val) != CMPI_RC_OK)
-                return "Missing `DevicePath' property";
+        msg = get_dev_paths(inst, 
+                            &pool->pool_info.disk.device_paths, 
+                            &pool->pool_info.disk.device_paths_ct);
+        
+        if (msg != NULL)
+                return msg;
 
-        pool->pool_info.disk.device_path = strdup(val);
+        if (pool->pool_info.disk.device_paths_ct != 1)
+                return "Specified pool type only takes one device path";
 
         if (cu_get_str_prop(inst, "Host", &val) != CMPI_RC_OK)
                 return "Missing `Host' property";




More information about the Libvirt-cim mailing list