When the 'string()' conversion is used the number is parsed inside
libvirt by our internal helpers which work on integers in contrast to
when 'number()' is used and libxml2 uses a 'double' variable internally.
On the upper extremes of the 64 bit variables the doulbe precision
variable doesn't have enough precision to represent each distinct
integer and thus could cause problems.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 6 +++---
src/conf/node_device_conf.c | 4 ++--
src/conf/storage_conf.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7dba65cfeb..7984a15c46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18103,10 +18103,10 @@ virDomainDefClockParse(virDomainDef *def,
break;
case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
- if (virXPathLongLong("number(./clock/@adjustment)", ctxt,
+ if (virXPathLongLong("string(./clock/@adjustment)", ctxt,
&def->clock.data.variable.adjustment) < 0)
def->clock.data.variable.adjustment = 0;
- if (virXPathLongLong("number(./clock/@adjustment0)", ctxt,
+ if (virXPathLongLong("string(./clock/@adjustment0)", ctxt,
&def->clock.data.variable.adjustment0) < 0)
def->clock.data.variable.adjustment0 = 0;
tmp = virXPathString("string(./clock/@basis)", ctxt);
@@ -18132,7 +18132,7 @@ virDomainDefClockParse(virDomainDef *def,
break;
case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE:
- if (virXPathULongLong("number(./clock/@start)", ctxt,
+ if (virXPathULongLong("string(./clock/@start)", ctxt,
&def->clock.data.starttime) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing 'start' attribute for clock with
offset='absolute'"));
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index b079c3713d..3bff17dae2 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1463,7 +1463,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt,
storage->media_label =
virXPathString("string(./media_label[1])", ctxt);
val = 0;
- if (virNodeDevCapsDefParseULongLong("number(./media_size[1])",
ctxt, &val, def,
+ if (virNodeDevCapsDefParseULongLong("string(./media_size[1])",
ctxt, &val, def,
_("no removable media size supplied
for '%s'"),
_("invalid removable media size
supplied for '%s'")) < 0) {
return -1;
@@ -1481,7 +1481,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt,
if (!(storage->flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE)) {
val = 0;
- if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt,
&val, def,
+ if (virNodeDevCapsDefParseULongLong("string(./size[1])", ctxt,
&val, def,
_("no size supplied for
'%s'"),
_("invalid size supplied for
'%s'")) < 0)
return -1;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 0f4fe1451e..b570679de2 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -720,7 +720,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
perms->uid = (uid_t) -1;
} else {
/* We previously could output -1, so continue to parse it */
- if (virXPathLongLong("number(./owner)", ctxt, &val) < 0 ||
+ if (virXPathLongLong("string(./owner)", ctxt, &val) < 0 ||
((uid_t)val != val &&
val != -1)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -735,7 +735,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
perms->gid = (gid_t) -1;
} else {
/* We previously could output -1, so continue to parse it */
- if (virXPathLongLong("number(./group)", ctxt, &val) < 0 ||
+ if (virXPathLongLong("string(./group)", ctxt, &val) < 0 ||
((gid_t) val != val &&
val != -1)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
--
2.37.3