From patchwork Wed Feb 3 14:41:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 39118B7D4D for ; Thu, 4 Feb 2010 02:06:46 +1100 (EST) Received: from localhost ([127.0.0.1]:40638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcgXO-0005bn-GW for incoming@patchwork.ozlabs.org; Wed, 03 Feb 2010 09:49:02 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcgPx-0001GN-Hp for qemu-devel@nongnu.org; Wed, 03 Feb 2010 09:41:21 -0500 Received: from [199.232.76.173] (port=38059 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcgPw-0001Fk-UH for qemu-devel@nongnu.org; Wed, 03 Feb 2010 09:41:20 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcgPv-0003lk-FT for qemu-devel@nongnu.org; Wed, 03 Feb 2010 09:41:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42232) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcgPu-0003le-Pf for qemu-devel@nongnu.org; Wed, 03 Feb 2010 09:41:19 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o13EfGJM024133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Feb 2010 09:41:17 -0500 Received: from localhost (vpn-11-121.rdu.redhat.com [10.11.11.121]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o13EfEvb015530; Wed, 3 Feb 2010 09:41:15 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 3 Feb 2010 12:41:01 -0200 Message-Id: <1265208064-16039-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265208064-16039-1-git-send-email-lcapitulino@redhat.com> References: <1265208064-16039-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH 2/5] block: BLOCK_IO_ERROR QMP event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This commit introduces the bdrv_mon_event() function, which should be called by block subsystems (eg. IDE) when a I/O error occurs, so that an QMP event is emitted. The following information is currently provided in the event: - device name - operation (ie. "read" or "write") - action taken (eg. "stop") Event example: { "event": "BLOCK_IO_ERROR", "data": { "device": "ide0-hd1", "operation": "write", "action": "stop" }, "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } Signed-off-by: Luiz Capitulino --- block.c | 29 +++++++++++++++++++++++++++++ block.h | 6 ++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 1919d19..2913124 100644 --- a/block.c +++ b/block.c @@ -1164,6 +1164,35 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, return bs->drv->bdrv_is_allocated(bs, sector_num, nb_sectors, pnum); } +void bdrv_mon_event(const BlockDriverState *bdrv, + BlockMonEventAction action, int is_read) +{ + QObject *data; + const char *action_str; + + switch (action) { + case BDRV_ACTION_REPORT: + action_str = "report"; + break; + case BDRV_ACTION_IGNORE: + action_str = "ignore"; + break; + case BDRV_ACTION_STOP: + action_str = "stop"; + break; + default: + abort(); + } + + data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }", + bdrv->device_name, + action_str, + is_read ? "read" : "write"); + monitor_protocol_event(QEVENT_BLOCK_IO_ERROR, data); + + qobject_decref(data); +} + static void bdrv_print_dict(QObject *obj, void *opaque) { QDict *bs_dict; diff --git a/block.h b/block.h index ecf66c5..a834300 100644 --- a/block.h +++ b/block.h @@ -44,6 +44,12 @@ typedef struct QEMUSnapshotInfo { #define BDRV_SECTOR_SIZE (1 << BDRV_SECTOR_BITS) #define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1); +typedef enum { + BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP +} BlockMonEventAction; + +void bdrv_mon_event(const BlockDriverState *bdrv, + BlockMonEventAction action, int is_read); void bdrv_info_print(Monitor *mon, const QObject *data); void bdrv_info(Monitor *mon, QObject **ret_data); void bdrv_stats_print(Monitor *mon, const QObject *data);