# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1239905650 25200
# Node ID 261a49710d0cb13c83e28f460583079db473d04f
# Parent 4574c6f289f29c9afd2bd3a3434360c17891e9fe
Add support for creating filesystem type storage pools
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 4574c6f289f2 -r 261a49710d0c libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Wed Apr 15 10:28:07 2009 -0700
+++ b/libxkutil/pool_parsing.c Thu Apr 16 11:14:10 2009 -0700
@@ -52,6 +52,11 @@
free(pool.forward_dev);
}
+static void cleanup_disk_pool(struct disk_pool pool) {
+ free(pool.path);
+ free(pool.device_path);
+}
+
void cleanup_virt_pool(struct virt_pool **pool)
{
struct virt_pool *_pool = *pool;
@@ -61,6 +66,8 @@
if (_pool->type == CIM_RES_TYPE_NET)
cleanup_net_pool(_pool->pool_info.net);
+ else if (_pool->type == CIM_RES_TYPE_DISK)
+ cleanup_disk_pool(_pool->pool_info.disk);
free(_pool->id);
free(_pool);
diff -r 4574c6f289f2 -r 261a49710d0c libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h Wed Apr 15 10:28:07 2009 -0700
+++ b/libxkutil/pool_parsing.h Thu Apr 16 11:14:10 2009 -0700
@@ -45,6 +45,7 @@
DISK_POOL_ISCSI,
DISK_POOL_LOGICAL} pool_type;
char *path;
+ char *device_path;
};
struct virt_pool {
diff -r 4574c6f289f2 -r 261a49710d0c libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Apr 15 10:28:07 2009 -0700
+++ b/libxkutil/xmlgen.c Thu Apr 16 11:14:10 2009 -0700
@@ -874,6 +874,8 @@
{
xmlNodePtr disk = NULL;
xmlNodePtr name = NULL;
+ xmlNodePtr src = NULL;
+ xmlNodePtr dev = NULL;
xmlNodePtr target = NULL;
xmlNodePtr path = NULL;
const char *type = NULL;
@@ -894,6 +896,21 @@
if (name == NULL)
goto out;
+ if (pool->device_path != NULL) {
+ src = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (src == NULL)
+ goto out;
+
+ dev = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST
NULL);
+ if (dev == NULL)
+ goto out;
+
+ if (xmlNewProp(dev,
+ BAD_CAST "path",
+ BAD_CAST pool->device_path) == NULL)
+ goto out;
+ }
+
target = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
if (target == NULL)
goto out;
diff -r 4574c6f289f2 -r 261a49710d0c schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof Wed Apr 15 10:28:07 2009 -0700
+++ b/schema/ResourceAllocationSettingData.mof Thu Apr 16 11:14:10 2009 -0700
@@ -207,6 +207,7 @@
"Disk, ISCSI, Logical"}]
uint16 Type;
string Path;
+ string DevicePath;
};
[Description ("KVM virtual disk pool settings"),
@@ -220,6 +221,7 @@
"Disk, ISCSI, Logical"}]
uint16 Type;
string Path;
+ string DevicePath;
};
[Description ("LXC virtual disk pool settings"),
@@ -233,5 +235,6 @@
"Disk, ISCSI, Logical"}]
uint16 Type;
string Path;
+ string DevicePath;
};
diff -r 4574c6f289f2 -r 261a49710d0c src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Wed Apr 15 10:28:07 2009 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c Thu Apr 16 11:14:10 2009 -0700
@@ -114,6 +114,25 @@
}
#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.path = NULL;
+}
+
+static const char *disk_fs_pool(CMPIInstance *inst,
+ struct virt_pool *pool)
+{
+ const char *val = NULL;
+
+ if (cu_get_str_prop(inst, "DevicePath", &val) != CMPI_RC_OK)
+ return "Missing `DevicePath' property";
+
+ pool->pool_info.disk.device_path = strdup(val);
+
+ return NULL;
+}
+
static const char *disk_rasd_to_pool(CMPIInstance *inst,
struct virt_pool *pool)
{
@@ -124,8 +143,19 @@
if (cu_get_u16_prop(inst, "Type", &type) != CMPI_RC_OK)
return "Missing `Type' property";
- if (type != DISK_POOL_DIR)
+ init_disk_pool(pool);
+
+ switch (type) {
+ case DISK_POOL_DIR:
+ break;
+ case DISK_POOL_FS:
+ msg = disk_fs_pool(inst, pool);
+ if (msg != NULL)
+ goto out;
+ break;
+ default:
return "Storage pool type not supported";
+ }
pool->pool_info.disk.pool_type = type;
@@ -134,6 +164,7 @@
pool->pool_info.disk.path = strdup(val);
+ out:
return msg;
}