[Libvirt-cim] [PATCH V2 28/48] Fix xml generation algorithm in bridge_net_to_xml()

Xu Wang cngesaint at gmail.com
Mon Oct 28 02:45:57 UTC 2013


Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
---
 libxkutil/xmlgen.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 3658d02..74b4a0d 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1208,24 +1208,40 @@ static const char *set_net_source(const char *root,
 }
 
 
-static const char *bridge_net_to_xml(xmlNodePtr nic, struct net_device *dev,
-                                     int domtype)
+static const char *bridge_net_to_xml(const char *root, struct net_device *dev,
+                                     int domtype, struct others **others)
 {
         const char *script = "vif-bridge";
-        xmlNodePtr tmp;
         const char *msg = NULL;
 
+        CU_DEBUG("Enter bridge_net_to_xml()");
+
        /* Scripts only supported on Xen guests see 'libvirt'
         * commit id 1734cdb99 (since 0.9.10) */
        if (domtype == DOMAIN_XENPV || domtype == DOMAIN_XENFV) {
-            tmp = xmlNewChild(nic, NULL, BAD_CAST "script", NULL);
-            if (tmp == NULL) {
+            *others = add_node_to_others(*others,
+                                         0,
+                                         "script",
+                                         NULL,
+                                         TYPE_NODE,
+                                         0,
+                                         root);
+
+            if (*others == NULL) {
+                    CU_DEBUG("add node <script> failed.");
                     return XML_ERROR;
             }
-            xmlNewProp(tmp, BAD_CAST "path", BAD_CAST script);
+
+            *others = add_node_to_others(*others,
+                                         0,
+                                         "path",
+                                         script,
+                                         TYPE_PROP,
+                                         0,
+                                         "script");
        }
 
-        msg = set_net_source(nic, dev, "bridge");
+        msg = set_net_source(root, dev, "bridge", others);
 
         return msg;
 }
-- 
1.7.1




More information about the Libvirt-cim mailing list