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

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


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

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index 097a5c8..46bd8f4 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1471,10 +1471,11 @@ static const char *net_xml(xmlNodePtr root, struct domain *dominfo)
 static const char *vcpu_xml(xmlNodePtr root, struct domain *dominfo)
 {
         struct vcpu_device *vcpu;
-        xmlNodePtr tmp;
         int ret;
         char *string = NULL;
 
+        CU_DEBUG("Enter vcpu_xml()");
+
         if (dominfo->dev_vcpu == NULL)
                 return NULL;
 
@@ -1484,13 +1485,24 @@ static const char *vcpu_xml(xmlNodePtr root, struct domain *dominfo)
         if (ret == -1)
                 return XML_ERROR;
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "vcpu", BAD_CAST string);
+        vcpu->others = add_node_to_others(vcpu->others,
+                                          0,
+                                          "vcpu",
+                                          string,
+                                          TYPE_NODE,
+                                          0,
+                                          "domain");
+
         free(string);
 
-        if (tmp == NULL)
+        if (vcpu->others == NULL) {
                 return XML_ERROR;
-        else
-                return NULL;
+        }
+
+        dominfo->others = combine_others(dominfo->others, vcpu->others);
+        vcpu->others = NULL;
+
+        return NULL;
 }
 
 #if LIBVIR_VERSION_NUMBER >= 9000
-- 
1.7.1




More information about the Libvirt-cim mailing list