From 4a89182077d721d5729c425ef6d85a4a763f5bc1 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 7 Feb 2007 13:44:22 +0000 Subject: [PATCH] Fix vcpu info for HVM guests --- ChangeLog | 6 ++++++ src/xml.c | 19 ++++++++++--------- tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr | 2 +- .../xml2sexpr-fv-vncunused.sexpr | 2 +- tests/xml2sexprdata/xml2sexpr-fv.sexpr | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21bdb056c..8c51a962a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 7 07:43:21 EST 2007 Daniel Berrange + + * 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 * configure.in, tests/Makefile.am: Only enable the low level diff --git a/src/xml.c b/src/xml.c index f1b3082a5..343d5f2e9 100644 --- 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); diff --git a/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr index 5b28406dd..ed3082ea3 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr @@ -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 diff --git a/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr index bd0d139bf..4f2fbe135 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr @@ -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 diff --git a/tests/xml2sexprdata/xml2sexpr-fv.sexpr b/tests/xml2sexprdata/xml2sexpr-fv.sexpr index 62513df8d..839910035 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv.sexpr @@ -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 -- 2.39.5