[Libvirt-cim] [PATCH 10/47] Fix xml parsing algorithm for parse_mem_device()

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


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

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index a6857a2..d41ad53 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1094,19 +1094,38 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs)
         struct virt_device *vdev = NULL;
         struct mem_device *mdev = NULL;
         char *content = NULL;
+        struct others *new_others = NULL;
+
+        CU_DEBUG("Enter parse_mem_device().");
 
         vdev = calloc(1, sizeof(*vdev));
-        if (vdev == NULL)
+        if (vdev == NULL) {
+                CU_DEBUG("calloc failed.");
                 goto err;
+        }
 
         mdev = &(vdev->dev.mem);
 
-        content = get_node_content(node);
+        new_others = parse_data_to_others(node, BAD_CAST "domain");
+        mdev->others = combine_others(mdev->others, new_others);
+
+        if (XSTREQ(node->name, "currentMemory")) {
+                content = fetch_from_others(&mdev->others,
+                                            "currentMemory",
+                                            TYPE_NODE,
+                                            "domain");
 
-        if (XSTREQ(node->name, "currentMemory"))
                 sscanf(content, "%" PRIu64, &mdev->size);
-        else if (XSTREQ(node->name, "memory"))
+        } else if (XSTREQ(node->name, "memory")) {
+                content = fetch_from_others(&mdev->others,
+                                            "memory",
+                                            TYPE_NODE,
+                                            "domain");
+
                 sscanf(content, "%" PRIu64, &mdev->maxsize);
+        } else {
+                /* do nothing */
+        }
 
         free(content);
 
-- 
1.7.1




More information about the Libvirt-cim mailing list