From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkg-0002C0-RK for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsWkX-00024N-Jb for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:38 -0400 Received: from mail-pd0-x232.google.com ([2607:f8b0:400e:c02::232]:34625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkX-000245-92 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:29 -0400 Received: by mail-pd0-f178.google.com with SMTP id v10so1014492pde.37 for ; Thu, 05 Jun 2014 05:26:28 -0700 (PDT) From: Wenchao Xia Date: Thu, 5 Jun 2014 05:22:16 -0700 Message-Id: <1401970944-18735-22-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 21/29] qapi event: convert BLOCK_IMAGE_CORRUPTED 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/qcow2-refcount.c | 14 ++++++++------ docs/qmp/qmp-events.txt | 22 ---------------------- qapi-event.json | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9507aef..2fca5a1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -27,6 +27,7 @@ #include "block/qcow2.h" #include "qemu/range.h" #include "qapi/qmp/types.h" +#include "qapi-event.h" static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size); static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, @@ -1807,7 +1808,6 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, } else if (ret > 0) { int metadata_ol_bitnr = ffs(ret) - 1; char *message; - QObject *data; assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR); @@ -1816,12 +1816,14 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, metadata_ol_names[metadata_ol_bitnr]); message = g_strdup_printf("Prevented %s overwrite", metadata_ol_names[metadata_ol_bitnr]); - data = qobject_from_jsonf("{ 'device': %s, 'msg': %s, 'offset': %" - PRId64 ", 'size': %" PRId64 " }", bs->device_name, message, - offset, size); - monitor_protocol_event(QEVENT_BLOCK_IMAGE_CORRUPTED, data); + qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs), + message, + true, + offset, + true, + size, + NULL); g_free(message); - qobject_decref(data); qcow2_mark_corrupt(bs); bs->drv = NULL; /* make BDS unusable */ diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index f67a9ec..eec3955 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -18,28 +18,6 @@ Example: "data": { "actual": 944766976 }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -BLOCK_IMAGE_CORRUPTED ---------------------- - -Emitted when a disk image is being marked corrupt. - -Data: - -- "device": Device name (json-string) -- "msg": Informative message (e.g., reason for the corruption) (json-string) -- "offset": If the corruption resulted from an image access, this is the access - offset into the image (json-int) -- "size": If the corruption resulted from an image access, this is the access - size (json-int) - -Example: - -{ "event": "BLOCK_IMAGE_CORRUPTED", - "data": { "device": "ide0-hd0", - "msg": "Prevented active L1 table overwrite", "offset": 196608, - "size": 65536 }, - "timestamp": { "seconds": 1378126126, "microseconds": 966463 } } - BLOCK_JOB_CANCELLED ------------------- diff --git a/qapi-event.json b/qapi-event.json index c889dbf..640eaa0 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -159,6 +159,28 @@ 'action': 'BlockErrorAction' } } ## +# @BLOCK_IMAGE_CORRUPTED +# +# Emitted when a disk image is being marked corrupt +# +# @device: device name +# +# @msg: informative message, for example, reason for the corruption +# +# @offset: #optional, if the corruption resulted from an image access, this is +# the access offset into the image +# @size: #optional, if the corruption resulted from an image access, this is +# the access size +# +# Since: 2.1 +## +{ 'event': 'BLOCK_IMAGE_CORRUPTED', + 'data': { 'device' : 'str', + 'msg' : 'str', + '*offset': 'int', + '*size' : 'int' } } + +## # @BLOCK_JOB_ERROR # # Emitted when a block job encounters an error -- 1.7.1