Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 89 +++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index c621b72..ad158ee 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -565,35 +565,80 @@ 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;
+ CU_DEBUG("Enter set_net_vsi()");
- tmp = xmlNewChild(nic, NULL, BAD_CAST "virtualport", NULL);
- if (tmp == NULL)
+ *others = add_node_to_others(*others,
+ "virtualport",
+ NULL,
+ TYPE_NODE,
+ 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,
+ "type",
+ dev->vsi_type,
+ TYPE_PROP,
+ "virtualport");
+
+ *others = add_node_to_others(*others,
+ "parameters",
+ NULL,
+ TYPE_NODE,
+ "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,
+ "profileid",
+ dev->profile_id,
+ TYPE_PROP,
+ "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,
+ "managerid",
+ dev->manager_id,
+ TYPE_PROP,
+ "parameters");
+ }
+
+ if (dev->type_id != NULL) {
+ *others = add_node_to_others(*others,
+ "typeid",
+ dev->type_id,
+ TYPE_PROP,
+ "parameters");
+ }
+
+ if (dev->type_id_version != NULL) {
+ *others = add_node_to_others(*others,
+ "typeidversion",
+ dev->type_id_version,
+ TYPE_PROP,
+ "parameters");
+ }
+
+ if (dev->instance_id != NULL) {
+ *others = add_node_to_others(*others,
+ "instanceid",
+ dev->instance_id,
+ TYPE_PROP,
+ "parameters");
+ }
}
return NULL;
--
1.7.1