Fix vcpu info for HVM guests

This commit is contained in:
Daniel P. Berrange 2007-02-07 13:44:22 +00:00
parent 5e395c2ac9
commit 4a89182077
5 changed files with 19 additions and 12 deletions

View File

@ -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> Wed Feb 7 07:40:21 EST 2007 Daniel Berrange <berrange@redhat.com>
* configure.in, tests/Makefile.am: Only enable the low level * configure.in, tests/Makefile.am: Only enable the low level

View File

@ -692,6 +692,7 @@ static int virDomainParseXMLGraphicsDescVFB(xmlNodePtr node, virBufferPtr buf)
* @node: node containing HVM OS description * @node: node containing HVM OS description
* @buf: a buffer for the result S-Expr * @buf: a buffer for the result S-Expr
* @ctxt: a path context representing the XML description * @ctxt: a path context representing the XML description
* @vcpus: number of virtual CPUs to configure
* @xendConfigVersion: xend configuration file format * @xendConfigVersion: xend configuration file format
* *
* Parse the OS part of the XML description for an HVM domain and add it to * 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. * Returns 0 in case of success, -1 in case of error.
*/ */
static int 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; xmlXPathObjectPtr obj = NULL;
xmlNodePtr cur, txt; xmlNodePtr cur, txt;
@ -758,6 +759,8 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
obj = NULL; obj = NULL;
virBufferVSprintf(buf, "(vcpus %d)", vcpus);
if (boot_dev) { if (boot_dev) {
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) { if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev); virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
@ -1285,6 +1288,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
int i, res; int i, res;
int bootloader = 0; int bootloader = 0;
int hvm = 0; int hvm = 0;
unsigned int vcpus = 1;
unsigned long mem = 0, max_mem = 0; unsigned long mem = 0, max_mem = 0;
if (name != NULL) if (name != NULL)
@ -1365,14 +1369,11 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)", mem, max_mem); virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)", mem, max_mem);
obj = xmlXPathEval(BAD_CAST "number(/domain/vcpu[1])", ctxt); obj = xmlXPathEval(BAD_CAST "number(/domain/vcpu[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NUMBER) || if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(isnan(obj->floatval)) || (obj->floatval <= 0)) { (!isnan(obj->floatval)) && (obj->floatval > 0)) {
virBufferVSprintf(&buf, "(vcpus 1)"); vcpus = (unsigned int) obj->floatval;
} else {
unsigned int cpu = (unsigned int) obj->floatval;
virBufferVSprintf(&buf, "(vcpus %u)", cpu);
} }
virBufferVSprintf(&buf, "(vcpus %u)", vcpus);
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt); obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
@ -1439,7 +1440,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
} else { } else {
hvm = 1; hvm = 1;
res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0],
&buf, ctxt, xendConfigVersion); &buf, ctxt, vcpus, xendConfigVersion);
} }
xmlXPathFreeObject(tmpobj); xmlXPathFreeObject(tmpobj);

View 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)))) (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))))

View 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)))) (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))))

View 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)))) (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))))