Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 164 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 136 insertions(+), 28 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index c7dbefb..f721ac7 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -763,26 +763,80 @@ static char *disk_block_xml(xmlNodePtr root, struct disk_device
*dev)
static const char *disk_file_xml(xmlNodePtr root, struct disk_device *dev)
{
- xmlNodePtr disk;
- xmlNodePtr tmp;
+ CU_DEBUG("Enter disk_file_xml()");
- disk = xmlNewChild(root, NULL, BAD_CAST "disk", NULL);
- if (disk == NULL)
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "disk",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "devices");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add tag <disk> failed.");
return XML_ERROR;
- xmlNewProp(disk, BAD_CAST "type", BAD_CAST "file");
- if (dev->device)
- xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
+ }
+
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "type",
+ "file",
+ TYPE_PROP,
+ 0,
+ "disk");
+
+ if (dev->device) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "device",
+ dev->device,
+ TYPE_PROP,
+ 0,
+ "disk");
+ }
if (dev->driver) {
- tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "driver",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "disk");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <driver> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver);
- if (dev->driver_type)
- xmlNewProp(tmp, BAD_CAST "type",
- BAD_CAST dev->driver_type);
- if (dev->cache)
- xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST
dev->cache);
+ }
+
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "name",
+ dev->driver,
+ TYPE_PROP,
+ 0,
+ "driver");
+
+ if (dev->driver_type) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "type",
+ dev->driver_type,
+ TYPE_PROP,
+ 0,
+ "driver");
+ }
+
+ if (dev->cache) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "cache",
+ dev->cache,
+ TYPE_PROP,
+ 0,
+ "driver");
+ }
}
if (dev->device != NULL && XSTREQ(dev->device, "cdrom")
&&
@@ -792,28 +846,82 @@ static const char *disk_file_xml(xmlNodePtr root, struct disk_device
*dev)
xml defination for libvirt should not have this defined in this
situation. */
} else {
- tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "source",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "disk");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <source> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
+ }
+
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "file",
+ dev->source,
+ TYPE_PROP,
+ 0,
+ "source");
}
- tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "target",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "disk");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <target> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->virtual_dev);
- if (dev->bus_type)
- xmlNewProp(tmp, BAD_CAST "bus", BAD_CAST dev->bus_type);
+ }
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "dev",
+ dev->virtual_dev,
+ TYPE_PROP,
+ 0,
+ "target");
- if (dev->readonly)
- xmlNewChild(disk, NULL, BAD_CAST "readonly", NULL);
+ if (dev->bus_type) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "bus",
+ dev->bus_type,
+ TYPE_PROP,
+ 0,
+ "target");
+ }
- if (dev->shareable)
- xmlNewChild(disk, NULL, BAD_CAST "shareable", NULL);
+ if (dev->readonly) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "readonly",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "disk");
+ }
+
+ if (dev->shareable) {
+ dev->others = add_node_to_others(dev->others,
+ 0,
+ "shareable",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "disk");
+ }
+ dev->others = others_to_xml(root, dev->others, 0, "devices");
- return NULL;
+ return check_others_active(dev->others);
}
static const char *disk_fs_xml(xmlNodePtr root, struct disk_device *dev)
--
1.7.1