Negative balloon values don't make sense, ignore them.

Reported-by: Mike Cao <b...@redhat.com>
Signed-off-by: Amit Shah <amit.s...@redhat.com>
---
I'm not sure if error_report is the right thing to use or should a new
qerror_report() be used.  Luiz, comments?

 balloon.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/balloon.c b/balloon.c
index cf9e3b2..e0ff97f 100644
--- a/balloon.c
+++ b/balloon.c
@@ -51,12 +51,16 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
     return 0;
 }
 
-static int qemu_balloon(ram_addr_t target)
+static int qemu_balloon(long long target)
 {
     if (!balloon_event_fn) {
         return 0;
     }
     trace_balloon_event(balloon_opaque, target);
+    if (target < 0) {
+        error_report("Ignoring negative balloon value");
+        return -1;
+    }
     balloon_event_fn(balloon_opaque, target);
     return 1;
 }
@@ -150,6 +154,8 @@ int do_balloon(Monitor *mon, const QDict *params,
     if (ret == 0) {
         qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
         return -1;
+    } else if (ret < 0) {
+        return -1;
     }
 
     cb(opaque, NULL);
-- 
1.7.6


Reply via email to