aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-01-13 17:43:25 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-01-29 10:02:26 +0100
commit6502a14734e71b2f6dd079b0a1e546e6aa2d2f8d (patch)
treecf6ca71770fbbca159b44b9075b37d869f4a8745
parenta6c90cbccdc07d51d4bbff71d2680f1a2c287370 (diff)
balloon: Inline qemu_balloon(), qemu_balloon_status()
... and simplify a bit. Permits factoring out common error checks in the next commit. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r--balloon.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/balloon.c b/balloon.c
index b70da4fa29..2884c2d37a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -62,25 +62,6 @@ void qemu_remove_balloon_handler(void *opaque)
balloon_opaque = NULL;
}
-static int qemu_balloon(ram_addr_t target)
-{
- if (!balloon_event_fn) {
- return 0;
- }
- trace_balloon_event(balloon_opaque, target);
- balloon_event_fn(balloon_opaque, target);
- return 1;
-}
-
-static int qemu_balloon_status(BalloonInfo *info)
-{
- if (!balloon_stat_fn) {
- return 0;
- }
- balloon_stat_fn(balloon_opaque, info);
- return 1;
-}
-
BalloonInfo *qmp_query_balloon(Error **errp)
{
BalloonInfo *info;
@@ -90,30 +71,33 @@ BalloonInfo *qmp_query_balloon(Error **errp)
return NULL;
}
- info = g_malloc0(sizeof(*info));
-
- if (qemu_balloon_status(info) == 0) {
+ if (!balloon_stat_fn) {
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon");
- qapi_free_BalloonInfo(info);
return NULL;
}
+ info = g_malloc0(sizeof(*info));
+ balloon_stat_fn(balloon_opaque, info);
return info;
}
-void qmp_balloon(int64_t value, Error **errp)
+void qmp_balloon(int64_t target, Error **errp)
{
if (kvm_enabled() && !kvm_has_sync_mmu()) {
error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return;
}
- if (value <= 0) {
+ if (target <= 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
return;
}
- if (qemu_balloon(value) == 0) {
+ if (!balloon_event_fn) {
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon");
+ return;
}
+
+ trace_balloon_event(balloon_opaque, target);
+ balloon_event_fn(balloon_opaque, target);
}