[Libvirt-cim] [PATCH 36/47] Fix xml generation algorithm in _xenpv_os_xml()

Xu Wang gesaint at linux.vnet.ibm.com
Tue Oct 8 06:14:10 UTC 2013


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

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 3dff548..f6d83a6 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1433,10 +1433,11 @@ static char *system_xml(xmlNodePtr root, struct domain *domain)
         return NULL;
 }
 
-static char *_xenpv_os_xml(xmlNodePtr root, struct domain *domain)
+static char *_xenpv_os_xml(const char *root, struct domain *domain)
 {
         struct pv_os_info *os = &domain->os_info.pv;
-        xmlNodePtr tmp;
+
+        CU_DEBUG("Enter _xenpv_os_xml()");
 
         if (os->type == NULL)
                 os->type = strdup("linux");
@@ -1444,21 +1445,49 @@ static char *_xenpv_os_xml(xmlNodePtr root, struct domain *domain)
         if (os->kernel == NULL)
                 os->kernel = strdup("/dev/null");
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
-        if (tmp == NULL)
+        domain->others = add_node_to_others(domain->others,
+                                            "type",
+                                            os->type,
+                                            TYPE_NODE,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <type> failed.");
                 return XML_ERROR;
+        }
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "kernel", BAD_CAST os->kernel);
-        if (tmp == NULL)
+        domain->others = add_node_to_others(domain->others,
+                                            "kernel",
+                                            os->kernel,
+                                            TYPE_NODE,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <kernel> failed.");
                 return XML_ERROR;
+        }
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "initrd", BAD_CAST os->initrd);
-        if (tmp == NULL)
+        domain->others = add_node_to_others(domain->others,
+                                            "initrd",
+                                            os->initrd,
+                                            TYPE_NODE,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <initrd> failed.");
                 return XML_ERROR;
+        }
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "cmdline", BAD_CAST os->cmdline);
-        if (tmp == NULL)
+        domain->others = add_node_to_others(domain->others,
+                                            "cmdline",
+                                            os->cmdline,
+                                            TYPE_NODE,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <cmdline> failed.");
                 return XML_ERROR;
+        }
 
         return NULL;
 }
-- 
1.7.1




More information about the Libvirt-cim mailing list