From: Luiz Capitulino <lcapitulino@redhat.com>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws
Subject: [Qemu-devel] [PULL 25/40] qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR
Date: Thu, 19 Jun 2014 15:39:37 -0400 [thread overview]
Message-ID: <1403206792-15387-26-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com>
From: Wenchao Xia <wenchaoqemu@gmail.com>
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
block.c | 36 ++++--------------------------------
blockjob.c | 6 +++++-
docs/qmp/qmp-events.txt | 47 -----------------------------------------------
include/block/block_int.h | 3 ---
qapi-schema.json | 14 ++++++++++++++
qapi/block-core.json | 39 +++++++++++++++++++++++++++++++++++++++
6 files changed, 62 insertions(+), 83 deletions(-)
diff --git a/block.c b/block.c
index 0d0e5cd..041f17a 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) {
@@ -3619,7 +3588,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, &error_abort);
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..ee2a6fb 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, &error_abort);
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 7aa2213..715c761 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -425,9 +425,6 @@ void bdrv_attach_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-schema.json b/qapi-schema.json
index 33d76bc..0a8df60 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3165,4 +3165,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' }
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b7f36c6..682864d 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1426,3 +1426,42 @@
##
{ 'enum': 'BlockErrorAction',
'data': [ 'ignore', 'report', 'stop' ] }
+
+
+##
+# @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: 0.13.0
+##
+{ '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: 1.3
+##
+{ 'event': 'BLOCK_JOB_ERROR',
+ 'data': { 'device' : 'str',
+ 'operation': 'IoOperationType',
+ 'action' : 'BlockdevOnError' } }
--
1.9.3
next prev parent reply other threads:[~2014-06-19 19:40 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 19:39 [Qemu-devel] [PULL for-2.1 00/40] QMP queue Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 01/40] qapi: fix coding style in parameters list Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 02/40] qapi: add const prefix to 'char *' insider c_type() Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 03/40] qapi: Suppress unwanted space between type and identifier Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 04/40] json-lexer: fix escaped backslash in single-quoted string Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 05/40] os-posix: include sys/time.h Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 06/40] qapi: Add includes from qapi/ as dependencies Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 07/40] qapi: add event helper functions Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 08/40] qapi script: add event support Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 09/40] test: add test cases for qapi event Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 10/40] qapi: adjust existing defines Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 11/40] monitor: add an implemention of qapi event emit method Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 12/40] qapi: add new schema file qapi-event.json Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 13/40] qapi event: convert SHUTDOWN Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 14/40] qapi event: convert POWERDOWN Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 15/40] qapi event: convert RESET Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 16/40] qapi event: convert STOP Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 17/40] qapi event: convert RESUME Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 18/40] qapi event: convert SUSPEND Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 19/40] qapi event: convert SUSPEND_DISK Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 20/40] qapi event: convert WAKEUP Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 21/40] qapi event: convert RTC_CHANGE Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 22/40] qapi event: convert WATCHDOG Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 23/40] qapi event: convert DEVICE_DELETED Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 24/40] qapi event: convert DEVICE_TRAY_MOVED Luiz Capitulino
2014-06-19 19:39 ` Luiz Capitulino [this message]
2014-06-19 19:39 ` [Qemu-devel] [PULL 26/40] qapi event: convert BLOCK_IMAGE_CORRUPTED Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 27/40] qapi event: convert other BLOCK_JOB events Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 28/40] qapi event: convert NIC_RX_FILTER_CHANGED Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 29/40] qapi event: convert VNC events Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 30/40] qapi event: convert SPICE events Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 31/40] qapi event: convert BALLOON_CHANGE Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 32/40] qapi event: convert GUEST_PANICKED Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 33/40] qapi event: convert QUORUM events Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 34/40] qapi event: clean up Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 35/40] qemu-char: introduce qemu_chr_alloc Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 36/40] qemu-char: do not call chr_write directly Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 37/40] qemu-char: move pty_chr_update_read_handler around Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 38/40] qemu-char: make writes thread-safe Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 39/40] monitor: protect outbuf and mux_out with mutex Luiz Capitulino
2014-06-19 19:39 ` [Qemu-devel] [PULL 40/40] monitor: protect event emission Luiz Capitulino
2014-06-20 18:24 ` [Qemu-devel] [PULL for-2.1 00/40] QMP queue Peter Maydell
2014-06-20 18:44 ` Luiz Capitulino
2014-06-20 19:17 ` Paolo Bonzini
2014-06-20 19:49 ` Paolo Bonzini
2014-06-20 20:02 ` Eric Blake
2014-06-24 13:08 ` Wenchao Xia
2014-06-24 13:20 ` Eric Blake
2014-06-24 13:24 ` Peter Maydell
2014-06-24 14:52 ` Wenchao Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403206792-15387-26-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).