From patchwork Fri Dec 9 11:49:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 130367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C425E1007D8 for ; Fri, 9 Dec 2011 22:50:49 +1100 (EST) Received: from localhost ([::1]:55938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYyyD-0006Wn-3U for incoming@patchwork.ozlabs.org; Fri, 09 Dec 2011 06:50:29 -0500 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 Received: from localhost (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB9BnpTh026558; Fri, 9 Dec 2011 06:49:52 -0500 From: Amit Shah To: qemu list Date: Fri, 9 Dec 2011 17:19:37 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Amit Shah , Markus Armbruster , Luiz Capitulino Subject: [Qemu-devel] [PATCH 2/3] balloon: report error if ballooning operation fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)