From ee58fe5303d47a773db08c0a019819cad7af6174 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Wed, 27 Jul 2011 16:50:54 +0530 Subject: [PATCH] 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 Signed-off-by: Amit Shah Reviewed-by: Markus Armbruster Acked-by: Michael S. Tsirkin --- balloon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- 2.7.4