* src/xml.c: markmc pointed out that using number(xpath) could lead

to NaN and following comparison would be wrong in a couple of places
  if the element looked at was missing.
Daniel
This commit is contained in:
Daniel Veillard 2006-08-10 14:26:35 +00:00
parent 098e0a4bdc
commit d42014f108
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,9 @@
Thu Aug 10 15:28:52 CEST 2006 Daniel Veillard <veillard@redhat.com>
* src/xml.c: markmc pointed out that using number(xpath) could lead
to NaN and following comparison would be wrong in a couple of places
if the element looked at was missing.
Wed Aug 9 10:17:03 EDT 2006 Daniel Berrange <berrange@redhat.com>
* src/driver.h, src/libvirt.c: Made the virDomainGetXMLDesc

View File

@ -18,6 +18,7 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <math.h> /* for isnan() */
#include "internal.h"
#include "hash.h"
#include "sexpr.h"
@ -999,7 +1000,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
obj = xmlXPathEval(BAD_CAST "number(/domain/memory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
(obj->floatval < 64000)) {
(isnan(obj->floatval)) || (obj->floatval < 64000)) {
virBufferVSprintf(&buf, "(memory 128)(maxmem 128)");
} else {
unsigned long mem = (obj->floatval / 1024);
@ -1010,7 +1011,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
obj = xmlXPathEval(BAD_CAST "number(/domain/vcpu[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
(obj->floatval <= 0)) {
(isnan(obj->floatval)) || (obj->floatval <= 0)) {
virBufferVSprintf(&buf, "(vcpus 1)");
} else {
unsigned int cpu = (unsigned int) obj->floatval;