qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Amit Shah <amit.shah@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
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	[thread overview]
Message-ID: <e01b77dd9dae28172f59c386e77cbcfdf2bd015a.1323431083.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1323431083.git.amit.shah@redhat.com>
In-Reply-To: <cover.1323431083.git.amit.shah@redhat.com>

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 <amit.shah@redhat.com>
---
 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

  reply	other threads:[~2011-12-09 11:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 11:49 [Qemu-devel] [PATCH 0/3] balloon: error if guest driver is not initialised Amit Shah
2011-12-09 11:49 ` Amit Shah [this message]
2011-12-09 11:49 ` [Qemu-devel] [PATCH 2/3] balloon: report error if ballooning operation fails Amit Shah
2011-12-09 11:49 ` [Qemu-devel] [PATCH 3/3] virtio-balloon: report error if balloon driver in guest not available Amit Shah
2011-12-09 11:55 ` [Qemu-devel] [PATCH 0/3] balloon: error if guest driver is not initialised Daniel P. Berrange
2011-12-09 12:02   ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e01b77dd9dae28172f59c386e77cbcfdf2bd015a.1323431083.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).