Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 6d91198..0323fb5 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1437,20 +1437,50 @@ static int parse_mem_device(xmlNode *node, struct virt_device
**vdevs)
char *content = NULL;
char *tmpval = NULL;
int ret = 0;
+ 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(new_others,
+ node,
+ 0,
+ BAD_CAST "domain");
+ mdev->others = combine_others(mdev->others, new_others);
+
+ if (XSTREQ(node->name, "currentMemory")) {
+ content = fetch_from_others(&mdev->others,
+ -1,
+ "currentMemory",
+ TYPE_NODE,
+ -1,
+ "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,
+ -1,
+ "memory",
+ TYPE_NODE,
+ -1,
+ "domain");
+
sscanf(content, "%" PRIu64, &mdev->maxsize);
- tmpval = get_attr_value(node, "dumpCore");
+
+ tmpval = fetch_from_others(&mdev->others,
+ -1,
+ "dumpCore",
+ TYPE_PROP,
+ -1,
+ "memory");
+
if (tmpval && XSTREQ(tmpval, "on")) {
mdev->dumpCore = MEM_DUMP_CORE_ON;
} else if (tmpval && XSTREQ(content, "off")) {
@@ -1458,6 +1488,8 @@ static int parse_mem_device(xmlNode *node, struct virt_device
**vdevs)
} else {
mdev->dumpCore = MEM_DUMP_CORE_NOT_SET;
}
+ } else {
+ /* do nothing */
}
*vdevs = vdev;
--
1.7.1