[Libvirt-cim] [PATCH 18/20] Fix xml parsing algorithm in parse_features()

John Ferlan jferlan at redhat.com
Fri Nov 15 00:24:07 UTC 2013


From: Xu Wang <cngesaint at gmail.com>

Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
---
 libxkutil/device_parsing.c | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 56c9d3d..43174c1 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -2774,17 +2774,35 @@ static int parse_os(struct domain *dominfo)
         return 1;
 }
 
-static int parse_features(struct domain *dominfo, xmlNode *features)
+static int parse_features(struct domain *dominfo)
 {
-        xmlNode *child;
+        CU_DEBUG("Enter parse_features()");
 
-        for (child = features->children; child != NULL; child = child->next) {
-                if (XSTREQ(child->name, "acpi"))
-                        dominfo->acpi = true;
-                else if (XSTREQ(child->name, "apic"))
-                        dominfo->apic = true;
-                else if (XSTREQ(child->name, "pae"))
-                        dominfo->pae = true;
+        if (seek_in_others(&dominfo->others,
+                           -1,
+                           "acpi",
+                           TYPE_NODE,
+                           -1,
+                           "features")) {
+                dominfo->acpi = true;
+        }
+
+        if (seek_in_others(&dominfo->others,
+                           -1,
+                           "apic",
+                           TYPE_NODE,
+                           -1,
+                           "features")) {
+                dominfo->apic = true;
+        }
+
+        if (seek_in_others(&dominfo->others,
+                           -1,
+                           "pae",
+                           TYPE_NODE,
+                           -1,
+                           "features")) {
+                dominfo->pae = true;
         }
 
         return 1;
@@ -2943,7 +2961,7 @@ static int parse_domain(xmlNodeSet *nsv, struct domain *dominfo)
                            TYPE_NODE,
                            -1,
                            (char *)nodes[0]->name)) {
-                /* parse_features(); */
+                parse_features(dominfo);
         }
 
         return 1;
-- 
1.8.3.1




More information about the Libvirt-cim mailing list