[Libvirt-cim] [PATCH 29/47] Fix xml generation algorithm in cputune_xml()

Xu Wang gesaint at linux.vnet.ibm.com
Tue Oct 8 06:14:03 UTC 2013


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

diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index b17ea51..ed00386 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -959,19 +959,27 @@ static const char *vcpu_xml(xmlNodePtr root, struct domain *dominfo)
 static const char *cputune_xml(xmlNodePtr root, struct domain *dominfo)
 {
         struct vcpu_device *vcpu;
-        xmlNodePtr cputune, tmp;
         int ret;
         char *string = NULL;
 
+        CU_DEBUG("Enter cputune_xml()");
+
         if (dominfo->dev_vcpu == NULL)
                 return NULL;
 
         vcpu = &dominfo->dev_vcpu[0].dev.vcpu;
 
         /* CPU cgroup setting saved by libvirt under <cputune> XML section */
-        cputune = xmlNewChild(root, NULL, BAD_CAST "cputune", NULL);
-        if (cputune == NULL)
+        vcpu->others = add_node_to_others(vcpu->others,
+                                          "cputune",
+                                          NULL,
+                                          TYPE_NODE,
+                                          "domain");
+
+        if (vcpu->others == NULL) {
+                CU_DEBUG("add node <cputune> failed.");
                 return XML_ERROR;
+        }
 
         /* Get the CPU cgroup setting from the VCPU RASD.Weight property */
         ret = asprintf(&string,
@@ -980,16 +988,22 @@ static const char *cputune_xml(xmlNodePtr root, struct domain *dominfo)
         if (ret == -1)
                 return XML_ERROR;
 
-        tmp = xmlNewChild(cputune,
-                          NULL,
-                          BAD_CAST "shares",
-                          BAD_CAST string);
+        vcpu->others = add_node_to_others(vcpu->others,
+                                          "shares",
+                                          string,
+                                          TYPE_NODE,
+                                          "cputune");
         free(string);
 
-        if (tmp == NULL)
+        if (vcpu->others == NULL) {
+                CU_DEBUG("add node <shares> failed.");
                 return XML_ERROR;
-        else
-                return NULL;
+        }
+
+        dominfo->others = combine_others(dominfo->others, vcpu->others);
+        vcpu->others = NULL;
+
+        return NULL;
 }
 #endif
 
-- 
1.7.1




More information about the Libvirt-cim mailing list