diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-07-27 16:50:54 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-04 16:43:09 -0500 |
commit | 514e73ecebc0aeadef218e91e36ee42b3d145c93 (patch) | |
tree | fb320a1db7f9e401e1832c5de193a99445aaf922 | |
parent | f76f665547f4a954a2c83552a88816fc2a316be0 (diff) |
balloon: Reject negative balloon values
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>
-rw-r--r-- | balloon.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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; |