[PATCH 0 of 3] Add support for logical type storage pools

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1245111972 25200 # Node ID dff67e06596528ece42c01eff9e0afbcc2a8a422 # Parent 416b44d9a9d4045587226707938610b732ff27ec Change DevicePath attribute to DevicePaths This is because logical storage pools can take more than one device path Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 416b44d9a9d4 -r dff67e065965 libxkutil/pool_parsing.c --- a/libxkutil/pool_parsing.c Fri Jun 19 11:38:35 2009 -0700 +++ b/libxkutil/pool_parsing.c Mon Jun 15 17:26:12 2009 -0700 @@ -53,10 +53,16 @@ } static void cleanup_disk_pool(struct disk_pool pool) { + uint16_t i; + free(pool.path); - free(pool.device_path); free(pool.host); free(pool.src_dir); + + for (i = 0; i < pool.device_paths_ct; i++) + free(pool.device_paths[i]); + + free(pool.device_paths); } void cleanup_virt_pool(struct virt_pool **pool) diff -r 416b44d9a9d4 -r dff67e065965 libxkutil/pool_parsing.h --- a/libxkutil/pool_parsing.h Fri Jun 19 11:38:35 2009 -0700 +++ b/libxkutil/pool_parsing.h Mon Jun 15 17:26:12 2009 -0700 @@ -45,7 +45,8 @@ DISK_POOL_ISCSI, DISK_POOL_LOGICAL} pool_type; char *path; - char *device_path; + char **device_paths; + uint16_t device_paths_ct; char *host; char *src_dir; }; diff -r 416b44d9a9d4 -r dff67e065965 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Fri Jun 19 11:38:35 2009 -0700 +++ b/schema/ResourceAllocationSettingData.mof Mon Jun 15 17:26:12 2009 -0700 @@ -229,7 +229,7 @@ "Disk, ISCSI, Logical"}] uint16 Type; string Path; - string DevicePath; + string DevicePaths[]; string Host; string SourceDirectory; }; @@ -245,7 +245,7 @@ "Disk, ISCSI, Logical"}] uint16 Type; string Path; - string DevicePath; + string DevicePaths[]; string Host; string SourceDirectory; }; @@ -261,7 +261,7 @@ "Disk, ISCSI, Logical"}] uint16 Type; string Path; - string DevicePath; + string DevicePaths[]; string Host; string SourceDirectory; };

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1245111972 25200 # Node ID 95e453b65affa4eb77bedfab60c954283e34f0ad # Parent dff67e06596528ece42c01eff9e0afbcc2a8a422 Change xmlgen and RPCC to use DevicePaths Signed-off-by: Kaitlin Rupert <karupert@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";

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1245113103 25200 # Node ID 82ac631405db90dd06173329df74ed90789660ee # Parent 95e453b65affa4eb77bedfab60c954283e34f0ad Add support for logical storage pools Note: These changes don't add support for creating the volume group (in the case where one doesn't already exist). That functionality will be added in a later patch. This means you will need an existing volume group already defined in order to test. For now, you can create a volume pool just by specifying the following attributes: -Type and Path (in the DiskPoolRASD) -ElementName (param of the CreateChildResourcePool() method). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 95e453b65aff -r 82ac631405db 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:45:03 2009 -0700 @@ -189,20 +189,28 @@ return NULL; } -static const char *disk_fs_or_disk_pool(CMPIInstance *inst, - struct virt_pool *pool) +static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, + struct virt_pool *pool) { const char *msg = NULL; msg = get_dev_paths(inst, &pool->pool_info.disk.device_paths, &pool->pool_info.disk.device_paths_ct); - - if (msg != NULL) - return msg; - if (pool->pool_info.disk.device_paths_ct != 1) - return "Specified pool type only takes one device path"; + + /* Specifying a value for DevicePaths isn't mandatory for logical + pool types. */ + if (pool->pool_info.disk.pool_type != DISK_POOL_LOGICAL) { + if (msg != NULL) + return msg; + + if (pool->pool_info.disk.device_paths_ct != 1) { + CU_DEBUG("%d only takes one device path", + pool->pool_info.disk.pool_type); + return "Specified pool type only takes one device path"; + } + } return NULL; } @@ -261,12 +269,15 @@ init_disk_pool(pool); + pool->pool_info.disk.pool_type = type; + switch (type) { case DISK_POOL_DIR: break; case DISK_POOL_FS: case DISK_POOL_DISK: - msg = disk_fs_or_disk_pool(inst, pool); + case DISK_POOL_LOGICAL: + msg = disk_fs_or_disk_or_logical_pool(inst, pool); break; case DISK_POOL_NETFS: msg = disk_netfs_pool(inst, pool); @@ -281,8 +292,6 @@ if (msg != NULL) goto out; - pool->pool_info.disk.pool_type = type; - if (cu_get_str_prop(inst, "Path", &val) != CMPI_RC_OK) return "Missing `Path' property";

+1 Kaitlin Rupert wrote:
This is the last type of storage pool left to support.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Richard Maciel, MSc IBM Linux Technology Center rmaciel@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel