From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYyxi-00056O-Kh for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYyxh-0008VL-Ef for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYyxg-0008VF-Tp for qemu-devel@nongnu.org; Fri, 09 Dec 2011 06:49:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB9BnrmF013359 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 9 Dec 2011 06:49:56 -0500 From: Amit Shah Date: Fri, 9 Dec 2011 17:19:37 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 2/3] balloon: report error if ballooning operation fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Markus Armbruster , Luiz Capitulino Ballooning operations can fail (e.g. driver in guest not available). Let the user know of such an error condition instead of silently ignoring errors. Signed-off-by: Amit Shah --- balloon.c | 7 +++++-- balloon.h | 2 +- hw/virtio-balloon.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/balloon.c b/balloon.c index 2b7131a..b05c9e2 100644 --- a/balloon.c +++ b/balloon.c @@ -63,12 +63,15 @@ void qemu_remove_balloon_handler(void *opaque) static int qemu_balloon(ram_addr_t target) { + int ret; + if (!balloon_event_fn) { return -1; } trace_balloon_event(balloon_opaque, target); - balloon_event_fn(balloon_opaque, target); - return 0; + ret = balloon_event_fn(balloon_opaque, target); + + return ret < 0 ? -1 : 0; } static int qemu_balloon_status(BalloonInfo *info) diff --git a/balloon.h b/balloon.h index b36abea..23b43bd 100644 --- a/balloon.h +++ b/balloon.h @@ -17,7 +17,7 @@ #include "monitor.h" #include "qapi-types.h" -typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); +typedef int (QEMUBalloonEvent)(void *opaque, ram_addr_t target); typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index e24a2bf..a8ecb51 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -180,7 +180,7 @@ static void virtio_balloon_stat(void *opaque, BalloonInfo *info) VIRTIO_BALLOON_PFN_SHIFT); } -static void virtio_balloon_to_target(void *opaque, ram_addr_t target) +static int virtio_balloon_to_target(void *opaque, ram_addr_t target) { VirtIOBalloon *dev = opaque; @@ -191,6 +191,7 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target) dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT; virtio_notify_config(&dev->vdev); } + return 0; } static void virtio_balloon_save(QEMUFile *f, void *opaque) -- 1.7.7.3