[Libvirt-cim] [PATCH V2 39/48] Fix xml generation algorithm in _xenfv_os_xml()

Xu Wang cngesaint at gmail.com
Mon Oct 28 02:46:08 UTC 2013


Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
---
 libxkutil/xmlgen.c |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 3c4fd30..4c5f731 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -2080,12 +2080,13 @@ static int _fv_bootlist_xml(const char *root, struct domain *domain)
         return 1;
 }
 
-static char *_xenfv_os_xml(xmlNodePtr root, struct domain *domain)
+static char *_xenfv_os_xml(const char *root, struct domain *domain)
 {
         struct fv_os_info *os = &domain->os_info.fv;
-        xmlNodePtr tmp;
         unsigned ret;
 
+        CU_DEBUG("Enter _xenfv_os_xml()");
+
         if (os->type == NULL)
                 os->type = strdup("hvm");
 
@@ -2098,15 +2099,33 @@ static char *_xenfv_os_xml(xmlNodePtr root, struct domain *domain)
                 os->bootlist[0] = strdup("hd");
         }
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
-        if (tmp == NULL)
-                return XML_ERROR;
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "type",
+                                            os->type,
+                                            TYPE_NODE,
+                                            0,
+                                            root);
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "loader", BAD_CAST os->loader);
-        if (tmp == NULL)
-                return XML_ERROR;
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <type> failed.");
+                return 0;
+        }
 
-        ret = _fv_bootlist_xml(root, os);
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "loader",
+                                            os->loader,
+                                            TYPE_NODE,
+                                            0,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <loader> failed.");
+                return 0;
+        }
+
+        ret = _fv_bootlist_xml(root, domain);
         if (ret == 0)
                 return XML_ERROR;
 
-- 
1.7.1




More information about the Libvirt-cim mailing list