Patchwork [v2,3/5] balloon: Ignore negative balloon values

login
register
mail settings
Submitter Amit Shah
Date July 28, 2011, 6:17 a.m.
Message ID <f1dd09d392a583aa03193b8a96a2d70393c58dbd.1311833521.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/107183/
State New
Headers show

Comments

Amit Shah - July 28, 2011, 6:17 a.m.
Negative balloon values don't make sense, ignore them.

Reported-by: Mike Cao <bcao@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 balloon.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Markus Armbruster - July 28, 2011, 7:31 a.m.
Amit Shah <amit.shah@redhat.com> writes:

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

Actually, they aren't ignored, they're rejected.
Amit Shah - July 28, 2011, 9:36 a.m.
On (Thu) 28 Jul 2011 [09:31:53], Markus Armbruster wrote:
> Amit Shah <amit.shah@redhat.com> writes:
> 
> > Negative balloon values don't make sense, ignore them.
> 
> Actually, they aren't ignored, they're rejected.

Will update commit log.

		Amit

Patch

diff --git a/balloon.c b/balloon.c
index 5200565..f56fdc1 100644
--- a/balloon.c
+++ b/balloon.c
@@ -140,6 +140,7 @@  int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
 int do_balloon(Monitor *mon, const QDict *params,
 	       MonitorCompletion cb, void *opaque)
 {
+    int64_t target;
     int ret;
 
     if (kvm_enabled() && !kvm_has_sync_mmu()) {
@@ -147,7 +148,12 @@  int do_balloon(Monitor *mon, const QDict *params,
         return -1;
     }
 
-    ret = qemu_balloon(qdict_get_int(params, "value"));
+    target = qdict_get_int(params, "value");
+    if (target <= 0) {
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
+        return -1;
+    }
+    ret = qemu_balloon(target);
     if (ret == 0) {
         qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
         return -1;