
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1241572138 25200 # Node ID 0bbc6afa622ccea1b57b5a92dbf228a61b6aee6b # Parent aa607e00fcf92c40f6fa3e5ca311f68433395661 Add XML generation for netfs disk pools Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r aa607e00fcf9 -r 0bbc6afa622c libxkutil/pool_parsing.c --- a/libxkutil/pool_parsing.c Fri May 01 13:02:34 2009 -0700 +++ b/libxkutil/pool_parsing.c Tue May 05 18:08:58 2009 -0700 @@ -55,6 +55,8 @@ static void cleanup_disk_pool(struct disk_pool pool) { free(pool.path); free(pool.device_path); + free(pool.host); + free(pool.src_dir); } void cleanup_virt_pool(struct virt_pool **pool) diff -r aa607e00fcf9 -r 0bbc6afa622c libxkutil/pool_parsing.h --- a/libxkutil/pool_parsing.h Fri May 01 13:02:34 2009 -0700 +++ b/libxkutil/pool_parsing.h Tue May 05 18:08:58 2009 -0700 @@ -46,6 +46,8 @@ DISK_POOL_LOGICAL} pool_type; char *path; char *device_path; + char *host; + char *src_dir; }; struct virt_pool { diff -r aa607e00fcf9 -r 0bbc6afa622c libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Fri May 01 13:02:34 2009 -0700 +++ b/libxkutil/xmlgen.c Tue May 05 18:08:58 2009 -0700 @@ -847,16 +847,61 @@ return NULL; } +static const char *set_disk_pool_source(xmlNodePtr disk, + struct disk_pool *pool) +{ + xmlNodePtr src; + xmlNodePtr tmp; + + src = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); + if (src == NULL) + return XML_ERROR; + + if (pool->device_path != NULL) { + 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) + return XML_ERROR; + } + + if (pool->host != NULL) { + tmp = xmlNewChild(src, NULL, BAD_CAST "host", BAD_CAST NULL); + if (tmp == NULL) + return XML_ERROR; + + if (xmlNewProp(tmp, + BAD_CAST "name", + BAD_CAST pool->host) == NULL) + return XML_ERROR; + } + + if (pool->src_dir != NULL) { + tmp = xmlNewChild(src, NULL, BAD_CAST "dir", BAD_CAST NULL); + if (tmp == NULL) + return XML_ERROR; + + if (xmlNewProp(tmp, + BAD_CAST "path", + BAD_CAST pool->src_dir) == NULL) + return XML_ERROR; + } + + return NULL; +} + static const char *disk_pool_xml(xmlNodePtr root, struct virt_pool *_pool) { xmlNodePtr disk = NULL; xmlNodePtr name = NULL; - xmlNodePtr src = NULL; - xmlNodePtr dev = NULL; xmlNodePtr target = NULL; xmlNodePtr path = NULL; const char *type = NULL; + const char *msg = NULL; struct disk_pool *pool = &_pool->pool_info.disk; type = disk_pool_type_to_str(pool->pool_type); @@ -874,19 +919,10 @@ 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; + if (pool->pool_type != DISK_POOL_DIR) { + msg = set_disk_pool_source(disk, pool); + if (msg != NULL) + return msg; } target = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);