[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3] balloon: Make functions return 0 on OK, -1 on e
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH 1/3] balloon: Make functions return 0 on OK, -1 on error. |
Date: |
Fri, 9 Dec 2011 17:19:36 +0530 |
Current semantics of 1 on OK and 0 on error are slightly weird.
qemu_balloon() and qemu_balloon_stats() do this. Other functions in the
file use the standard 0 and -1 return values. This commit makes the
file consistent in returning such values.
Signed-off-by: Amit Shah <address@hidden>
---
balloon.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/balloon.c b/balloon.c
index e1cd5fa..2b7131a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -64,25 +64,26 @@ void qemu_remove_balloon_handler(void *opaque)
static int qemu_balloon(ram_addr_t target)
{
if (!balloon_event_fn) {
- return 0;
+ return -1;
}
trace_balloon_event(balloon_opaque, target);
balloon_event_fn(balloon_opaque, target);
- return 1;
+ return 0;
}
static int qemu_balloon_status(BalloonInfo *info)
{
if (!balloon_stat_fn) {
- return 0;
+ return -1;
}
balloon_stat_fn(balloon_opaque, info);
- return 1;
+ return 0;
}
BalloonInfo *qmp_query_balloon(Error **errp)
{
BalloonInfo *info;
+ int ret;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
@@ -91,7 +92,8 @@ BalloonInfo *qmp_query_balloon(Error **errp)
info = g_malloc0(sizeof(*info));
- if (qemu_balloon_status(info) == 0) {
+ ret = qemu_balloon_status(info);
+ if (ret < 0) {
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon");
qapi_free_BalloonInfo(info);
return NULL;
@@ -120,7 +122,7 @@ int do_balloon(Monitor *mon, const QDict *params,
return -1;
}
ret = qemu_balloon(target);
- if (ret == 0) {
+ if (ret < 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
--
1.7.7.3