Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 104 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 83 insertions(+), 21 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index a4094d8..5bfdc81 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1090,46 +1090,108 @@ static const char *emu_xml(xmlNodePtr root, struct domain
*dominfo)
static const char *graphics_vnc_xml(xmlNodePtr root,
struct graphics_device *dev)
{
- xmlNodePtr tmp = NULL;
+ CU_DEBUG("Enter graphics_vnc_xml()");
- tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
- if (tmp == NULL)
+ dev->others = add_node_to_others(dev->others,
+ "graphics",
+ NULL,
+ TYPE_NODE,
+ "devices");
+
+ if (dev->others == NULL) {
+ CU_DEBUG("add node <graphics> failed.");
return XML_ERROR;
+ }
- xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
+ dev->others = add_node_to_others(dev->others,
+ "type",
+ dev->type,
+ TYPE_PROP,
+ "graphics");
if (STREQC(dev->type, "sdl")) {
if (dev->dev.sdl.display) {
- xmlNewProp(tmp, BAD_CAST "display",
- BAD_CAST dev->dev.sdl.display);
+ dev->others = add_node_to_others(dev->others,
+ "display",
+ dev->dev.sdl.display,
+ TYPE_PROP,
+ "graphics");
}
if (dev->dev.sdl.xauth) {
- xmlNewProp(tmp, BAD_CAST "xauth",
- BAD_CAST dev->dev.sdl.xauth);
+ dev->others = add_node_to_others(dev->others,
+ "xauth",
+ dev->dev.sdl.xauth,
+ TYPE_PROP,
+ "graphics");
}
if (dev->dev.sdl.fullscreen) {
- xmlNewProp(tmp, BAD_CAST "fullscreen",
- BAD_CAST dev->dev.sdl.fullscreen);
+ dev->others = add_node_to_others(dev->others,
+ "fullscreen",
+ dev->dev.sdl.fullscreen,
+ TYPE_PROP,
+ "graphics");
}
return NULL;
}
if (dev->dev.vnc.port) {
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST
dev->dev.vnc.port);
- if (STREQC(dev->dev.vnc.port, "-1"))
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST
"yes");
- else
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST
"no");
+ dev->others = add_node_to_others(dev->others,
+ "port",
+ dev->dev.vnc.port,
+ TYPE_PROP,
+ "graphics");
+ /* Just fetch autoport from others or the following code
+ * would add the attribution twice. These function calling
+ * would removed after the feature about others tags
+ * management finished. */
+ fetch_from_others(&dev->others,
+ "autoport",
+ TYPE_PROP,
+ "graphics");
+
+ if (STREQC(dev->dev.vnc.port, "-1")) {
+ dev->others = add_node_to_others(dev->others,
+ "autoport",
+ "yes",
+ TYPE_PROP,
+ "graphics");
+ } else {
+ dev->others = add_node_to_others(dev->others,
+ "autoport",
+ "no",
+ TYPE_PROP,
+ "graphics");
+ }
}
- if (dev->dev.vnc.host)
- xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST
dev->dev.vnc.host);
+ if (dev->dev.vnc.host) {
+ dev->others = add_node_to_others(dev->others,
+ "listen",
+ dev->dev.vnc.host,
+ TYPE_PROP,
+ "graphics");
+ }
- if (dev->dev.vnc.passwd)
- xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST
dev->dev.vnc.passwd);
+ if (dev->dev.vnc.passwd) {
+ dev->others = add_node_to_others(dev->others,
+ "passwd",
+ dev->dev.vnc.passwd,
+ TYPE_PROP,
+ "graphics");
+ }
+
+ if (dev->dev.vnc.keymap) {
+ dev->others = add_node_to_others(dev->others,
+ "keymap",
+ dev->dev.vnc.keymap,
+ TYPE_PROP,
+ "graphics");
+ }
- if (dev->dev.vnc.keymap)
- xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST
dev->dev.vnc.keymap);
+ dev->others = others_to_xml(root, dev->others, "devices");
+ if (dev->others) {
+ CU_DEBUG("others_to_xml failed.");
+ }
return NULL;
}
--
1.7.1