[Libvirt-cim] [PATCH 09/20] Fix xml parsing algorithm for parse_emu_device()

John Ferlan jferlan at redhat.com
Fri Nov 15 00:23:58 UTC 2013


From: Xu Wang <cngesaint at gmail.com>

Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
---
 libxkutil/device_parsing.c | 24 +++++++++++++++++++++---
 libxkutil/device_parsing.h |  1 +
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 8082b37..5fdf28e 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -165,6 +165,7 @@ static void cleanup_emu_device(struct emu_device *dev)
                 return;
 
         free(dev->path);
+        cleanup_others(dev->others);
 }
 
 static void cleanup_vnc_device(struct graphics_device *dev)
@@ -1506,15 +1507,32 @@ static int parse_emu_device(xmlNode *node, struct virt_device **vdevs)
         struct virt_device *vdev = NULL;
         struct emu_device *edev = NULL;
 
+        CU_DEBUG("Enter parse_emu_device().");
+
         vdev = calloc(1, sizeof(*vdev));
-        if (vdev == NULL)
+        if (vdev == NULL) {
+                CU_DEBUG("calloc failed.");
                 goto err;
+        }
 
         edev = &(vdev->dev.emu);
 
-        edev->path = get_node_content(node);
-        if (edev->path == NULL)
+        edev->others = parse_data_to_others(edev->others,
+                                            node,
+                                            0,
+                                            BAD_CAST "devices");
+
+        edev->path = fetch_from_others(&edev->others,
+                                       -1,
+                                       (char *)node->name,
+                                       TYPE_NODE,
+                                       -1,
+                                       "devices");
+
+        if (edev->path == NULL) {
+                CU_DEBUG("no path");
                 goto err;
+        }
 
         vdev->type = CIM_RES_TYPE_EMU;
 
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index c9e2b29..c5517e3 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -120,6 +120,7 @@ struct vcpu_device {
 
 struct emu_device {
         char *path;
+        struct others *others;
 };
 
 struct vnc_device {
-- 
1.8.3.1




More information about the Libvirt-cim mailing list