From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkW-0001wh-Mh for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsWkN-000217-Bp for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:28 -0400 Received: from mail-pb0-x231.google.com ([2607:f8b0:400e:c01::231]:51554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkN-00020t-0E for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:19 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so1038300pbb.8 for ; Thu, 05 Jun 2014 05:26:18 -0700 (PDT) From: Wenchao Xia Date: Thu, 5 Jun 2014 05:22:15 -0700 Message-Id: <1401970944-18735-21-git-send-email-wenchaoqemu@gmail.com> In-Reply-To: <1401970944-18735-1-git-send-email-wenchaoqemu@gmail.com> References: <1401970944-18735-1-git-send-email-wenchaoqemu@gmail.com> Subject: [Qemu-devel] [PATCH V6 20/29] qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, Wenchao Xia , lcapitulino@redhat.com Signed-off-by: Wenchao Xia --- block.c | 36 +++------------------------------ blockjob.c | 6 ++++- docs/qmp/qmp-events.txt | 47 --------------------------------------------- include/block/block_int.h | 3 -- qapi-event.json | 38 ++++++++++++++++++++++++++++++++++++ qapi-schema.json | 14 +++++++++++++ 6 files changed, 61 insertions(+), 83 deletions(-) diff --git a/block.c b/block.c index 52f4580..1ebbce6 100644 --- a/block.c +++ b/block.c @@ -24,7 +24,6 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "qemu/module.h" @@ -2133,36 +2132,6 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, bs->dev_opaque = opaque; } -void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, - enum MonitorEvent ev, - BlockErrorAction action, bool is_read) -{ - QObject *data; - const char *action_str; - - switch (action) { - case BLOCK_ERROR_ACTION_REPORT: - action_str = "report"; - break; - case BLOCK_ERROR_ACTION_IGNORE: - action_str = "ignore"; - break; - case BLOCK_ERROR_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(ev, data); - - qobject_decref(data); -} - static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) { if (bs->dev_ops && bs->dev_ops->change_media_cb) { @@ -3612,7 +3581,10 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, bool is_read, int error) { assert(error >= 0); - bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); + qapi_event_send_block_io_error(bdrv_get_device_name(bs), + is_read ? IO_OPERATION_TYPE_READ : + IO_OPERATION_TYPE_WRITE, + action, NULL); if (action == BLOCK_ERROR_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(bs, error); diff --git a/blockjob.c b/blockjob.c index bc63d42..43f971d 100644 --- a/blockjob.c +++ b/blockjob.c @@ -34,6 +34,7 @@ #include "block/coroutine.h" #include "qmp-commands.h" #include "qemu/timer.h" +#include "qapi-event.h" void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, @@ -277,7 +278,10 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, default: abort(); } - bdrv_emit_qmp_error_event(job->bs, QEVENT_BLOCK_JOB_ERROR, action, is_read); + qapi_event_send_block_job_error(bdrv_get_device_name(bs), + is_read ? IO_OPERATION_TYPE_READ : + IO_OPERATION_TYPE_WRITE, + action, NULL); if (action == BLOCK_ERROR_ACTION_STOP) { block_job_pause(job); block_job_iostatus_set_err(job, error); diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 1ee6f53..f67a9ec 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -40,31 +40,6 @@ Example: "size": 65536 }, "timestamp": { "seconds": 1378126126, "microseconds": 966463 } } -BLOCK_IO_ERROR --------------- - -Emitted when a disk I/O error occurs. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored - "report": error has been reported to the device - "stop": error caused VM to be stopped - -Example: - -{ "event": "BLOCK_IO_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -Note: If action is "stop", a STOP event will eventually follow the -BLOCK_IO_ERROR event. - BLOCK_JOB_CANCELLED ------------------- @@ -118,28 +93,6 @@ Example: "speed": 0 }, "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } -BLOCK_JOB_ERROR ---------------- - -Emitted when a block job encounters an error. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored, the job may fail later - "report": error will be reported and the job canceled - "stop": error caused job to be paused - -Example: - -{ "event": "BLOCK_JOB_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - BLOCK_JOB_READY --------------- diff --git a/include/block/block_int.h b/include/block/block_int.h index f2e753f..0995316 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -399,9 +399,6 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs); #ifdef _WIN32 int is_windows_drive(const char *filename); #endif -void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, - enum MonitorEvent ev, - BlockErrorAction action, bool is_read); /** * stream_start: diff --git a/qapi-event.json b/qapi-event.json index c2c65f9..c889dbf 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -137,3 +137,41 @@ ## { 'event': 'DEVICE_TRAY_MOVED', 'data': { 'device': 'str', 'tray-open': 'bool' } } + +## +# @BLOCK_IO_ERROR +# +# Emitted when a disk I/O error occurs +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Note: If action is "stop", a STOP event will eventually follow the +# BLOCK_IO_ERROR event +# +# Since: 2.1 +## +{ 'event': 'BLOCK_IO_ERROR', + 'data': { 'device': 'str', 'operation': 'IoOperationType', + 'action': 'BlockErrorAction' } } + +## +# @BLOCK_JOB_ERROR +# +# Emitted when a block job encounters an error +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Since: 2.1 +## +{ 'event': 'BLOCK_JOB_ERROR', + 'data': { 'device' : 'str', + 'operation': 'IoOperationType', + 'action' : 'BlockdevOnError' } } diff --git a/qapi-schema.json b/qapi-schema.json index a14504d..23be2bf 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4823,4 +4823,18 @@ { 'enum': 'WatchdogExpirationAction', 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] } +## +# @IoOperationType +# +# An enumeration of the I/O operation types +# +# @read: read operation +# +# @write: write operation +# +# Since: 2.1 +## +{ 'enum': 'IoOperationType', + 'data': [ 'read', 'write' ] } + { 'include': 'qapi-event.json' } -- 1.7.1