From 853a67106eaf6eae188e63d0399c22daef132c46 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Mon, 1 Aug 2011 11:40:57 -0300 Subject: [RHEL6 qemu-kvm PATCH 56/65] balloon: Reject negative balloon values RH-Author: Amit Shah Message-id: Patchwork-id: 30730 O-Subject: [RHEL6.2 qemu PATCH 11/13] balloon: Reject negative balloon values Bugzilla: 694373 RH-Acked-by: Markus Armbruster RH-Acked-by: Jes Sorensen RH-Acked-by: Alex Williamson 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 (cherry picked from commit 9843621e3b03d36aa64d57abedc6d03bde464dd3) Bugzilla: 694373 Signed-off-by: Amit Shah --- balloon.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) Signed-off-by: Eduardo Habkost --- balloon.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/balloon.c b/balloon.c index 7a8a457..2a6dfe6 100644 --- a/balloon.c +++ b/balloon.c @@ -141,6 +141,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()) { @@ -148,7 +149,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; -- 1.7.3.2