From: Xu Wang <cngesaint(a)gmail.com>
Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 89 ++++++++++++++++++++++++++++++++++------------
1 file changed, 66 insertions(+), 23 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index dac2ea1..940b105 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1129,40 +1129,83 @@ static int parse_disk_device(xmlNode *dnode, struct virt_device
**vdevs)
}
}
-static int parse_vsi_device(xmlNode *dnode, struct net_device *vdevs)
+static int parse_vsi_device(struct others **others, struct net_device *vdevs)
{
struct vsi_device *vsi_dev = NULL;
- xmlNode * child = NULL;
+
+ CU_DEBUG("Enter parse_vsi_device().");
vsi_dev = calloc(1, sizeof(*vsi_dev));
- if (vsi_dev == NULL)
+ if (vsi_dev == NULL) {
+ CU_DEBUG("calloc failed.");
goto err;
+ }
- vsi_dev->vsi_type = get_attr_value(dnode, "type");
- if (vsi_dev->vsi_type == NULL)
+ vsi_dev->vsi_type = fetch_from_others(others,
+ -1,
+ "type",
+ TYPE_PROP,
+ -1,
+ "virtualport");
+ if (vsi_dev->vsi_type == NULL) {
+ CU_DEBUG("no vsi type");
goto err;
+ }
- for (child = dnode->children; child != NULL; child = child->next) {
- if (XSTREQ(child->name, "parameters")) {
- vsi_dev->manager_id = get_attr_value(child,
- "managerid");
- if (vsi_dev->manager_id == NULL)
- goto err;
+ if (seek_in_others(others,
+ -1,
+ "parameters",
+ TYPE_NODE,
+ -1,
+ "virtualport")) {
+ vsi_dev->manager_id = fetch_from_others(others,
+ -1,
+ "managerid",
+ TYPE_PROP,
+ -1,
+ "parameters");
+
+ if (vsi_dev->manager_id == NULL) {
+ CU_DEBUG("no managerid");
+ goto err;
+ }
- vsi_dev->type_id = get_attr_value(child, "typeid");
- if (vsi_dev->type_id == NULL)
- goto err;
+ vsi_dev->type_id = fetch_from_others(others,
+ -1,
+ "typeid",
+ TYPE_PROP,
+ -1,
+ "parameters");
+ if (vsi_dev->type_id == NULL) {
+ CU_DEBUG("no typeid");
+ goto err;
+ }
- vsi_dev->type_id_version =
- get_attr_value(child, "typeidversion");
- if (vsi_dev->type_id_version == NULL)
- goto err;
+ vsi_dev->type_id_version = fetch_from_others(others,
+ -1,
+ "typeidversion",
+ TYPE_PROP,
+ -1,
+ "parameters");
- vsi_dev->instance_id = get_attr_value(child,
- "instanceid");
- vsi_dev->profile_id = get_attr_value(child,
- "profileid");
- }
+ if (vsi_dev->type_id_version == NULL) {
+ CU_DEBUG("no typeidversion");
+ goto err;
+ }
+
+ vsi_dev->instance_id = fetch_from_others(others,
+ -1,
+ "instanceid",
+ TYPE_PROP,
+ -1,
+ "parameters");
+
+ vsi_dev->profile_id = fetch_from_others(others,
+ -1,
+ "profileid",
+ TYPE_PROP,
+ -1,
+ "parameters");
}
memcpy(&(vdevs->vsi), vsi_dev, sizeof(*vsi_dev));
--
1.8.3.1