
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/xmlgen.c | 57 ++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 44 insertions(+), 13 deletions(-) diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index a963ca3..3658d02 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1152,26 +1152,57 @@ 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, + 0, + "source", + NULL, + TYPE_NODE, + 0, + 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, + 0, + "dev", + dev->source, + TYPE_PROP, + 0, + "source"); + + if (dev->net_mode != NULL) { + *others = add_node_to_others(*others, + 0, + "mode", + dev->net_mode, + TYPE_PROP, + 0, + "source"); + } + } else { + *others = add_node_to_others(*others, + 0, + src_type, + dev->source, + TYPE_PROP, + 0, + "source"); + } + } else { return XML_ERROR; + } return NULL; } -- 1.7.1