[Libvirt-cim] [PATCH 2 of 2] Add VCPU XML generation

Dan Smith danms at us.ibm.com
Tue Jan 15 16:35:08 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1200415539 28800
# Node ID 0339dbd4e4898d409cc4a276a0197e71aec99937
# Parent  f90450901ee0e616bda311a5da2e7d14c570f6fa
Add VCPU XML generation

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r f90450901ee0 -r 0339dbd4e489 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Tue Jan 15 08:33:39 2008 -0800
+++ b/libxkutil/xmlgen.c	Tue Jan 15 08:45:39 2008 -0800
@@ -197,8 +197,21 @@ static bool net_to_xml(char **xml, struc
 
 static bool vcpu_to_xml(char **xml, struct virt_device *dev)
 {
-        astrcat(xml, "<vcpu>1</vcpu>\n");
-        return true;
+        int count;
+        int ret;
+
+        if (*xml == NULL) {
+                ret = asprintf(xml, "<vcpu>1</vcpu>");
+                return ret != -1;
+        }
+
+        if (sscanf(*xml, "<vcpu>%i</vcpu>\n", &count) != 1)
+                return false;
+
+        free(*xml);
+        ret = asprintf(xml, "<vcpu>%i</vcpu>\n", count + 1);
+
+        return ret != -1;
 }
 
 static bool mem_to_xml(char **xml, struct virt_device *dev)




More information about the Libvirt-cim mailing list