On Fri, Mar 13, 2015 at 05:15:32PM +0800, Luyao Huang wrote:
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.


Where to start.  NACK to this patch as is.  Domains that have
INT_MAX < period < UINT_MAX will disappear after libvirt is restarted
and that's not backwards compatible.

I couldn't make sense of the commit message, but at least the aim is
visible from the code.  Anyway, I believe Erik already worked on this
issue as I gave him few hints regarding this on one of his patches.
Did you talk together about it?  It would be a pity if the work was
blindly doubled.

Looking at this commit message I made a diff to squash in, so I'll
post a v2 with it.

Signed-off-by: Luyao Huang <lhu...@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgp86x3oXTMvw.pgp
Description: PGP signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to