Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/xmlgen.c | 49 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index ad158ee..859cc21 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -644,26 +644,49 @@ static const char *set_net_vsi(const char *root,
return NULL;
}
-static const char *set_net_source(xmlNodePtr nic,
+static const char *set_net_source(const char *root,
struct net_device *dev,
- const char *src_type)
+ const char *src_type,
+ struct others **others)
{
- xmlNodePtr tmp;
+ CU_DEBUG("Enter set_net_source()");
if (dev->source != NULL) {
- tmp = xmlNewChild(nic, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
+ *others = add_node_to_others(*others,
+ "source",
+ NULL,
+ TYPE_NODE,
+ root);
+
+ if (*others == NULL) {
+ CU_DEBUG("add node <source> failed.");
return XML_ERROR;
+ }
+
if (STREQ(src_type, "direct")) {
- xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST
dev->source);
- if (dev->net_mode != NULL)
- xmlNewProp(tmp, BAD_CAST "mode",
- BAD_CAST dev->net_mode);
- } else
- xmlNewProp(tmp, BAD_CAST src_type,
- BAD_CAST dev->source);
- } else
+ *others = add_node_to_others(*others,
+ "dev",
+ dev->source,
+ TYPE_PROP,
+ "source");
+
+ if (dev->net_mode != NULL) {
+ *others = add_node_to_others(*others,
+ "mode",
+ dev->net_mode,
+ TYPE_PROP,
+ "source");
+ }
+ } else {
+ *others = add_node_to_others(*others,
+ src_type,
+ dev->source,
+ TYPE_PROP,
+ "source");
+ }
+ } else {
return XML_ERROR;
+ }
return NULL;
}
--
1.7.1