From patchwork Mon Feb 1 18:07:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44215 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 55AD2B7D70 for ; Tue, 2 Feb 2010 05:24:42 +1100 (EST) Received: from localhost ([127.0.0.1]:43891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nc0lQ-0007Vo-UI for incoming@patchwork.ozlabs.org; Mon, 01 Feb 2010 13:12:44 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nc0h8-0006fz-8I for qemu-devel@nongnu.org; Mon, 01 Feb 2010 13:08:18 -0500 Received: from [199.232.76.173] (port=57569 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nc0h7-0006fh-Mr for qemu-devel@nongnu.org; Mon, 01 Feb 2010 13:08:17 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nc0h5-0006pN-T0 for qemu-devel@nongnu.org; Mon, 01 Feb 2010 13:08:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48318) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nc0h5-0006p9-DJ for qemu-devel@nongnu.org; Mon, 01 Feb 2010 13:08:15 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o11I8ELX006175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 1 Feb 2010 13:08:14 -0500 Received: from localhost (vpn-9-68.rdu.redhat.com [10.11.9.68]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o11I8C7Z004604; Mon, 1 Feb 2010 13:08:13 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 1 Feb 2010 16:07:48 -0200 Message-Id: <1265047668-15039-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265047668-15039-1-git-send-email-lcapitulino@redhat.com> References: <1265047668-15039-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH 2/2] QMP: Introduce DISK_ERROR 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 It's emitted when a disk write or read fails, some device information is provided. We can also provide error details in the future. Example: { "event": "DISK_ERROR", "data": { "device": "ide0-hd1", "operation": "write", "action": "stop" } "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } NOTE: Adding a small reference in QMP/qmp-events.txt, but this file is wrong and will be replaced by proper documentation shortly. Signed-off-by: Luiz Capitulino --- QMP/qmp-events.txt | 7 +++++++ monitor.c | 3 +++ monitor.h | 1 + vl.c | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 1 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index dc48ccc..e968ef5 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -43,3 +43,10 @@ Data: 'server' and 'client' keys with the same keys as 'query-vnc'. Description: Issued when the VNC session is made active. Data: 'server' and 'client' keys with the same keys as 'query-vnc'. + +7 DISK_ERROR +------------ + +Description: Issued when a disk I/O error occurs +Data: 'device' (device name), 'action' (action to be taken), + 'operation' ("read" or "write") diff --git a/monitor.c b/monitor.c index fb7c572..82edd79 100644 --- a/monitor.c +++ b/monitor.c @@ -378,6 +378,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_VNC_DISCONNECTED: event_name = "VNC_DISCONNECTED"; break; + case QEVENT_DISK_ERROR: + event_name = "DISK_ERROR"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index b0f9270..beaddaf 100644 --- a/monitor.h +++ b/monitor.h @@ -23,6 +23,7 @@ typedef enum MonitorEvent { QEVENT_VNC_CONNECTED, QEVENT_VNC_INITIALIZED, QEVENT_VNC_DISCONNECTED, + QEVENT_DISK_ERROR, QEVENT_MAX, } MonitorEvent; diff --git a/vl.c b/vl.c index 57c439d..1f69f56 100644 --- a/vl.c +++ b/vl.c @@ -1856,10 +1856,42 @@ static BlockInterfaceErrorAction drive_get_err_action( return is_read ? BLOCK_ERR_REPORT : BLOCK_ERR_STOP_ENOSPC; } +static void driver_err_event( + BlockInterfaceErrorAction action, int is_read, const char *device) +{ + QObject *data; + const char *action_str; + + switch (action) { + case BLOCK_ERR_REPORT: + action_str = "report"; + break; + case BLOCK_ERR_IGNORE: + action_str = "ignore"; + break; + case BLOCK_ERR_STOP_ANY: + case BLOCK_ERR_STOP_ENOSPC: + action_str = "stop"; + break; + default: + abort(); + } + + data = qobject_from_jsonf("{'device': %s, 'action': %s, 'operation': %s}", + device, action_str, is_read ? "read" : "write"); + monitor_protocol_event(QEVENT_DISK_ERROR, data); + qobject_decref(data); +} + BlockInterfaceErrorAction drive_get_on_error( BlockDriverState *bdrv, int is_read) { - return drive_get_err_action(bdrv, is_read); + BlockInterfaceErrorAction action; + + action = drive_get_err_action(bdrv, is_read); + driver_err_event(action, is_read, bdrv->device_name); + + return action; } static void bdrv_format_print(void *opaque, const char *name)