[Libvirt-cim] [PATCH 40/47] Fix xml generation algorithm in _lxc_os_xml()

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


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

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index fcd701c..36593d4 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1603,21 +1603,36 @@ static char *_kvm_os_xml(const char *root, struct domain *domain)
         return NULL;
 }
 
-static char *_lxc_os_xml(xmlNodePtr root, struct domain *domain)
+static char *_lxc_os_xml(const char *root, struct domain *domain)
 {
         struct lxc_os_info *os = &domain->os_info.lxc;
-        xmlNodePtr tmp;
+
+        CU_DEBUG("Enter _lxc_os_xml()");
 
         if (os->type == NULL)
                 os->type = strdup("exe");
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "init", BAD_CAST os->init);
-        if (tmp == NULL)
+        domain->others = add_node_to_others(domain->others,
+                                            "init",
+                                            os->init,
+                                            TYPE_NODE,
+                                            root);
+
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <init> failed.");
                 return XML_ERROR;
+        }
 
-        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;
+        }
 
         return NULL;
 }
-- 
1.7.1




More information about the Libvirt-cim mailing list