[libvirt] [PATCH] conf: fix use the wrong type for period

Luyao Huang lhuang at redhat.com
Fri Mar 13 09:15:32 UTC 2015


https://bugzilla.redhat.com/show_bug.cgi?id=1140958

When we set period as unsigned int max value 4294967295 and
start the vm, qemu will report error. This becuase we define period
as a unsigned int and parse it as a unsigned int, but we use it as
a int when set it via QMP in qemuMonitorJSONSetMemoryStatsPeriod,
so 4294967295 turn to -1 when we send the QMP command.

After check the qemu's code this value type should be int, and found
a qemu commit 1f9296b for this values range.

Seems no other hypervisor vm use this so i add a check when we parse it.

Signed-off-by: Luyao Huang <lhuang at redhat.com>
---
 src/conf/domain_conf.c | 3 ++-
 src/conf/domain_conf.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 127fc91..54bd5aa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10452,7 +10452,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
     }
 
     ctxt->node = node;
-    if (virXPathUInt("string(./stats/@period)", ctxt, &def->period) < -1) {
+    if (virXPathInt("string(./stats/@period)", ctxt, &def->period) < -1 ||
+        def->period < 0) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("invalid statistics collection period"));
         goto error;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ea463cb..ee0f5fd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1556,7 +1556,7 @@ enum {
 struct _virDomainMemballoonDef {
     int model;
     virDomainDeviceInfo info;
-    unsigned int period; /* seconds between collections */
+    int period; /* seconds between collections */
 };
 
 struct _virDomainNVRAMDef {
-- 
1.8.3.1




More information about the libvir-list mailing list