Skip to content

Commit

Permalink
balloon: Reject negative balloon values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
amit3s authored and Anthony Liguori committed Aug 4, 2011
1 parent f76f665 commit 514e73e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,20 @@ 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()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
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;
Expand Down

0 comments on commit 514e73e

Please sign in to comment.