Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 101 ++++++++++++++++++++++++++++++++++---------
1 files changed, 80 insertions(+), 21 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index e95b0a9..adb3146 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -705,7 +705,8 @@ static int parse_fs_device(xmlNode *dnode, struct virt_device
**vdevs)
{
struct virt_device *vdev = NULL;
struct disk_device *ddev = NULL;
- xmlNode *child = NULL;
+
+ CU_DEBUG("Enter parse_fs_device().");
vdev = calloc(1, sizeof(*vdev));
if (vdev == NULL)
@@ -713,35 +714,93 @@ static int parse_fs_device(xmlNode *dnode, struct virt_device
**vdevs)
ddev = (&vdev->dev.disk);
- ddev->type = get_attr_value(dnode, "type");
+ ddev->others = parse_data_to_others(ddev->others,
+ dnode,
+ 0,
+ BAD_CAST "devices");
+ if (ddev->others == NULL) {
+ CU_DEBUG("parse xml failed.");
+ goto err;
+ }
+
+ /* fetch out <disk> tag from others. It will be removed
+ * after others management finished. */
+ fetch_from_others(&ddev->others,
+ -1,
+ "filesystem",
+ TYPE_NODE,
+ -1,
+ "devices");
+
+ ddev->type = fetch_from_others(&ddev->others,
+ -1,
+ "type",
+ TYPE_PROP,
+ -1,
+ (char *)dnode->name);
if (ddev->type == NULL) {
CU_DEBUG("No type");
goto err;
}
- ddev->access_mode = get_attr_value(dnode, "accessmode");
+ ddev->access_mode = fetch_from_others(&ddev->others,
+ -1,
+ "accessmode",
+ TYPE_PROP,
+ -1,
+ (char *)dnode->name);
+
+ if (seek_in_others(&ddev->others,
+ -1,
+ "source",
+ TYPE_NODE,
+ -1,
+ (char *)dnode->name)) {
+ ddev->source = fetch_from_others(&ddev->others,
+ -1,
+ "dir",
+ TYPE_PROP,
+ -1,
+ "source");
+
+
+ if (ddev->source == NULL) {
+ CU_DEBUG("no source dir");
+ goto err;
+ }
+ }
- for (child = dnode->children; child != NULL; child = child->next) {
- if (XSTREQ(child->name, "source")) {
- ddev->source = get_attr_value(child, "dir");
- if (ddev->source == NULL) {
- CU_DEBUG("No source dir");
- goto err;
- }
- } else if (XSTREQ(child->name, "target")) {
- ddev->virtual_dev = get_attr_value(child, "dir");
- if (ddev->virtual_dev == NULL) {
- CU_DEBUG("No target dir");
- goto err;
- }
- } else if (XSTREQ(child->name, "driver")) {
- ddev->driver_type = get_attr_value(child, "type");
+ if (seek_in_others(&ddev->others,
+ -1,
+ "target",
+ TYPE_NODE,
+ -1,
+ (char *)dnode->name)) {
+ ddev->virtual_dev = fetch_from_others(&ddev->others,
+ -1,
+ "dir",
+ TYPE_PROP,
+ -1,
+ "target");
+
+ if (ddev->virtual_dev == NULL) {
+ CU_DEBUG("no target dir");
+ goto err;
}
}
- if ((ddev->source == NULL) || (ddev->virtual_dev == NULL)) {
- CU_DEBUG("S: %s D: %s", ddev->source,
ddev->virtual_dev);
- goto err;
+ if (seek_in_others(&ddev->others,
+ -1,
+ "driver",
+ TYPE_NODE,
+ -1,
+ (char *)dnode->name)) {
+ ddev->driver_type = fetch_from_others(&ddev->others,
+ -1,
+ "type",
+ TYPE_PROP,
+ -1,
+ "driver");
}
ddev->disk_type = DISK_FS;
--
1.7.1