
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/xmlgen.c | 127 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 105 insertions(+), 22 deletions(-) diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 3855443..5979e96 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1665,48 +1665,131 @@ 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, + 0, + "graphics", + NULL, + TYPE_NODE, + 0, + "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, + 0, + "type", + dev->type, + TYPE_PROP, + 0, + "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, + 0, + "display", + dev->dev.sdl.display, + TYPE_PROP, + 0, + "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, + 0, + "xauth", + dev->dev.sdl.xauth, + TYPE_PROP, + 0, + "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, + 0, + "fullscreen", + dev->dev.sdl.fullscreen, + TYPE_PROP, + 0, + "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, + 0, + "port", + dev->dev.vnc.port, + TYPE_PROP, + 0, + "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, + 0, + "autoport", + TYPE_PROP, + 0, + "graphics"); + + if (STREQC(dev->dev.vnc.port, "-1")) { + dev->others = add_node_to_others(dev->others, + 0, + "autoport", + "yes", + TYPE_PROP, + 0, + "graphics"); + } else { + dev->others = add_node_to_others(dev->others, + 0, + "autoport", + "no", + TYPE_PROP, + 0, + "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, + 0, + "listen", + dev->dev.vnc.host, + TYPE_PROP, + 0, + "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, + 0, + "passwd", + dev->dev.vnc.passwd, + TYPE_PROP, + 0, + "graphics"); + } - if (dev->dev.vnc.keymap) - xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->dev.vnc.keymap); + if (dev->dev.vnc.keymap) { + dev->others = add_node_to_others(dev->others, + 0, + "keymap", + dev->dev.vnc.keymap, + TYPE_PROP, + 0, + "graphics"); + } - return NULL; + dev->others = others_to_xml(root, dev->others, 0, "devices"); + + return check_others_active(dev->others); } static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) -- 1.7.1