Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 107 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 84 insertions(+), 23 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 3350e80..a963ca3 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1057,35 +1057,96 @@ static const char *disk_xml(xmlNodePtr root, struct domain
*dominfo)
return msg;
}
-static const char *set_net_vsi(xmlNodePtr nic, struct vsi_device *dev)
+static const char *set_net_vsi(const char *root,
+ struct vsi_device *dev,
+ struct others **others)
{
- xmlNodePtr tmp;
-
- tmp = xmlNewChild(nic, NULL, BAD_CAST "virtualport", NULL);
- if (tmp == NULL)
+ CU_DEBUG("Enter set_net_vsi()");
+
+ *others = add_node_to_others(*others,
+ 0,
+ "virtualport",
+ NULL,
+ TYPE_NODE,
+ 0,
+ root);
+
+ if (*others == NULL) {
+ CU_DEBUG("add node <virtualport> failed.");
return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->vsi_type);
+ }
- tmp = xmlNewChild(tmp, NULL, BAD_CAST "parameters", NULL);
- if (tmp == NULL)
+ *others = add_node_to_others(*others,
+ 0,
+ "type",
+ dev->vsi_type,
+ TYPE_PROP,
+ 0,
+ "virtualport");
+
+ *others = add_node_to_others(*others,
+ 0,
+ "parameters",
+ NULL,
+ TYPE_NODE,
+ 0,
+ "virtualport");
+
+ if (*others == NULL) {
+ CU_DEBUG("add node <parameters> failed.");
return XML_ERROR;
+ }
+
if (STREQ(dev->vsi_type, "802.1Qbh")) {
- if (dev->profile_id != NULL)
- xmlNewProp(tmp, BAD_CAST "profileid",
- BAD_CAST dev->profile_id);
+ if (dev->profile_id != NULL) {
+ *others = add_node_to_others(*others,
+ 0,
+ "profileid",
+ dev->profile_id,
+ TYPE_PROP,
+ 0,
+ "parameters");
+ }
} else {
- if (dev->manager_id != NULL)
- xmlNewProp(tmp, BAD_CAST "managerid",
- BAD_CAST dev->manager_id);
- if (dev->type_id != NULL)
- xmlNewProp(tmp, BAD_CAST "typeid",
- BAD_CAST dev->type_id);
- if (dev->type_id_version != NULL)
- xmlNewProp(tmp, BAD_CAST "typeidversion",
- BAD_CAST dev->type_id_version);
- if (dev->instance_id != NULL)
- xmlNewProp(tmp, BAD_CAST "instanceid",
- BAD_CAST dev->instance_id);
+ if (dev->manager_id != NULL) {
+ *others = add_node_to_others(*others,
+ 0,
+ "managerid",
+ dev->manager_id,
+ TYPE_PROP,
+ 0,
+ "parameters");
+ }
+
+ if (dev->type_id != NULL) {
+ *others = add_node_to_others(*others,
+ 0,
+ "typeid",
+ dev->type_id,
+ TYPE_PROP,
+ 0,
+ "parameters");
+ }
+
+ if (dev->type_id_version != NULL) {
+ *others = add_node_to_others(*others,
+ 0,
+ "typeidversion",
+ dev->type_id_version,
+ TYPE_PROP,
+ 0,
+ "parameters");
+ }
+
+ if (dev->instance_id != NULL) {
+ *others = add_node_to_others(*others,
+ 0,
+ "instanceid",
+ dev->instance_id,
+ TYPE_PROP,
+ 0,
+ "parameters");
+ }
}
return NULL;
--
1.7.1