Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 79 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 66 insertions(+), 13 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 5c151d3..c621b72 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -447,12 +447,18 @@ static const char *disk_file_xml(xmlNodePtr root, struct disk_device
*dev)
static const char *disk_fs_xml(xmlNodePtr root, struct disk_device *dev)
{
- xmlNodePtr fs;
- xmlNodePtr tmp;
+ CU_DEBUG("Enter disk_fs_xml()");
- fs = xmlNewChild(root, NULL, BAD_CAST "filesystem", NULL);
- if (fs == NULL)
+ dev->others = add_node_to_others(dev->others,
+ "filesystem",
+ NULL,
+ TYPE_NODE,
+ "devices");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <filesystem> failed.");
return XML_ERROR;
+ }
/* filesystem prop 'type' not needed to be generated, as it defaults
to 'mount' in libvirt, the only supported value for now. */
@@ -461,23 +467,70 @@ static const char *disk_fs_xml(xmlNodePtr root, struct disk_device
*dev)
So generate here if specified by user, else leave it to libvirt. */
if (dev->access_mode) {
- xmlNewProp(fs, BAD_CAST "accessmode", BAD_CAST
dev->access_mode);
+ dev->others = add_node_to_others(dev->others,
+ "accessmode",
+ dev->access_mode,
+ TYPE_PROP,
+ "filesystem");
}
if(dev->driver_type) {
- tmp = xmlNewChild(fs, NULL, BAD_CAST "driver", NULL);
- xmlNewProp(tmp, BAD_CAST "type", BAD_CAST
dev->driver_type);
+ dev->others = add_node_to_others(dev->others,
+ "driver",
+ NULL,
+ TYPE_NODE,
+ "filesystem");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <driver> failed.");
+ return XML_ERROR;
+ }
+
+ dev->others = add_node_to_others(dev->others,
+ "type",
+ dev->driver_type,
+ TYPE_PROP,
+ "driver");
}
- tmp = xmlNewChild(fs, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ "source",
+ NULL,
+ TYPE_NODE,
+ "filesystem");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <source> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "dir", BAD_CAST dev->source);
+ }
- tmp = xmlNewChild(fs, NULL, BAD_CAST "target", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ "dir",
+ dev->source,
+ TYPE_PROP,
+ "source");
+
+ dev->others = add_node_to_others(dev->others,
+ "target",
+ NULL,
+ TYPE_NODE,
+ "filesystem");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <target> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "dir", BAD_CAST dev->virtual_dev);
+ }
+
+ dev->others = add_node_to_others(dev->others,
+ "dir",
+ dev->virtual_dev,
+ TYPE_PROP,
+ "target");
+
+ dev->others = others_to_xml(root, dev->others, "devices");
+ if (dev->others) {
+ CU_DEBUG("others_to_xml failed.");
+ }
return NULL;
}
--
1.7.1