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

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


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

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 4bce159..10a04a6 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -2256,20 +2256,44 @@ static char *os_xml(xmlNodePtr root, struct domain *domain)
 
 static char *features_xml(xmlNodePtr root, struct domain *domain)
 {
-        xmlNodePtr features;
+        CU_DEBUG("Enter features_xml()");
 
-        features = xmlNewChild(root, NULL, BAD_CAST "features", NULL);
-        if (features == NULL)
-                return "Failed to allocate XML memory";
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "features",
+                                            NULL,
+                                            TYPE_NODE,
+                                            0,
+                                            "domain");
 
-        if (domain->acpi)
-                xmlNewChild(features, NULL, BAD_CAST "acpi", NULL);
+        if (domain->others == NULL) {
+                CU_DEBUG("add node <features> failed.");
+                return XML_ERROR;
+        }
 
-        if (domain->apic)
-                xmlNewChild(features, NULL, BAD_CAST "apic", NULL);
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "acpi",
+                                            NULL,
+                                            TYPE_NODE,
+                                            0,
+                                            "features");
+
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "apic",
+                                            NULL,
+                                            TYPE_NODE,
+                                            0,
+                                            "features");
 
-        if (domain->pae)
-                xmlNewChild(features, NULL, BAD_CAST "pae", NULL);
+        domain->others = add_node_to_others(domain->others,
+                                            0,
+                                            "pae",
+                                            NULL,
+                                            TYPE_NODE,
+                                            0,
+                                            "features");
 
         return NULL;
 }
-- 
1.7.1




More information about the Libvirt-cim mailing list