]> git.proxmox.com Git - qemu.git/commitdiff
balloon: Reject negative balloon values
authorAmit Shah <amit.shah@redhat.com>
Wed, 27 Jul 2011 11:20:54 +0000 (16:50 +0530)
committerAmit Shah <amit.shah@redhat.com>
Thu, 28 Jul 2011 09:40:27 +0000 (15:10 +0530)
Negative balloon values don't make sense, reject them and throw a qerror
with QERR_INVALID_PARAMETER_VALUE.

Reported-by: Mike Cao <bcao@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
balloon.c

index 5200565cb27d88d08fde9b1cd3452641460fbe62..f56fdc1c4b5018d1cf3fec1132e122d78e6940c5 100644 (file)
--- 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;