]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix vcpu info for HVM guests
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 7 Feb 2007 13:44:22 +0000 (13:44 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 7 Feb 2007 13:44:22 +0000 (13:44 +0000)
ChangeLog
src/xml.c
tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr
tests/xml2sexprdata/xml2sexpr-fv.sexpr

index 21bdb056c7353a55a195ffa23d993132daeadbbe..8c51a962a5b99a208b445519c1466fe33e6ab970 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Feb  7 07:43:21 EST 2007 Daniel Berrange <berrange@redhat.com>
+
+       * src/xml.c, tests/xml2sexprdata/*.sexpr: Also include the
+       vcpu info in the (image (hvm))  part of the SEXPR for fully
+       virt guests, so it gets passed on into QEMU.
+
 Wed Feb  7 07:40:21 EST 2007 Daniel Berrange <berrange@redhat.com>
 
        * configure.in, tests/Makefile.am: Only enable the low level
index f1b3082a5365dbab668b9a1a9f3f775cfe80c174..343d5f2e9f7f2d05e6b1ab8b6e7ffa1462e7c4c8 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -692,6 +692,7 @@ static int virDomainParseXMLGraphicsDescVFB(xmlNodePtr node, virBufferPtr buf)
  * @node: node containing HVM OS description
  * @buf: a buffer for the result S-Expr
  * @ctxt: a path context representing the XML description
+ * @vcpus: number of virtual CPUs to configure
  * @xendConfigVersion: xend configuration file format
  *
  * Parse the OS part of the XML description for an HVM domain and add it to
@@ -702,7 +703,7 @@ static int virDomainParseXMLGraphicsDescVFB(xmlNodePtr node, virBufferPtr buf)
  * Returns 0 in case of success, -1 in case of error.
  */
 static int
-virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion)
+virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int vcpus, int xendConfigVersion)
 {
     xmlXPathObjectPtr obj = NULL;
     xmlNodePtr cur, txt;
@@ -758,6 +759,8 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
     xmlXPathFreeObject(obj);
     obj = NULL;
 
+    virBufferVSprintf(buf, "(vcpus %d)", vcpus);
+
     if (boot_dev) {
        if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
           virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
@@ -1285,6 +1288,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
     int i, res;
     int bootloader = 0;
     int hvm = 0;
+    unsigned int vcpus = 1;
     unsigned long mem = 0, max_mem = 0;
 
     if (name != NULL)
@@ -1365,14 +1369,11 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
     virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)", mem, max_mem);
 
     obj = xmlXPathEval(BAD_CAST "number(/domain/vcpu[1])", ctxt);
-    if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
-        (isnan(obj->floatval)) || (obj->floatval <= 0)) {
-        virBufferVSprintf(&buf, "(vcpus 1)");
-    } else {
-        unsigned int cpu = (unsigned int) obj->floatval;
-
-        virBufferVSprintf(&buf, "(vcpus %u)", cpu);
+    if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
+        (!isnan(obj->floatval)) && (obj->floatval > 0)) {
+        vcpus = (unsigned int) obj->floatval;
     }
+    virBufferVSprintf(&buf, "(vcpus %u)", vcpus);
     xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
@@ -1439,7 +1440,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
            } else {
                hvm = 1;
                res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0],
-                                                &buf, ctxt, xendConfigVersion);
+                                         &buf, ctxt, vcpus, xendConfigVersion);
            }
 
            xmlXPathFreeObject(tmpobj);
index 5b28406dd54c0418c65b3484dc4b879ad0b8eb29..ed3082ea3c43ea40f1c4674f030b1e0af6283037 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncdisplay 17)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(vnc 1)(vncdisplay 17)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index bd0d139bf4145738ae0c1eb33cb9cb99ba146b3b..4f2fbe135367a12abc7ec20f802eed64edafb75e 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncunused 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(vnc 1)(vncunused 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index 62513df8dfcb4bafbdf8a146c471eb7bd8231194..839910035b228b6e0fbb5e2047de2b3a081514a0 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(cdrom '/root/boot.iso')(acpi 1)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file