From patchwork Mon Jun 23 16:36:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 363053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 82A46140077 for ; Tue, 24 Jun 2014 02:52:57 +1000 (EST) Received: from localhost ([::1]:54967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz7UF-0006kg-HS for incoming@patchwork.ozlabs.org; Mon, 23 Jun 2014 12:52:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz7FB-0003od-P8 for qemu-devel@nongnu.org; Mon, 23 Jun 2014 12:37:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz7F4-00041g-3P for qemu-devel@nongnu.org; Mon, 23 Jun 2014 12:37:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz7F3-00041O-Se for qemu-devel@nongnu.org; Mon, 23 Jun 2014 12:37:14 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5NGb7iq023604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Jun 2014 12:37:08 -0400 Received: from localhost (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5NGb7hn005568; Mon, 23 Jun 2014 12:37:07 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Mon, 23 Jun 2014 12:36:28 -0400 Message-Id: <1403541403-16468-29-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1403541403-16468-1-git-send-email-lcapitulino@redhat.com> References: <1403541403-16468-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 28/43] qapi event: convert BLOCK_IMAGE_CORRUPTED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Wenchao Xia Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- block/qcow2-refcount.c | 14 ++++++++------ docs/qmp/qmp-events.txt | 22 ---------------------- qapi/block-core.json | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9507aef..cc6cf74 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, + &error_abort); 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 56bd145..796405a 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -28,28 +28,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/block-core.json b/qapi/block-core.json index 682864d..2dbac42 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1429,6 +1429,30 @@ ## +# @BLOCK_IMAGE_CORRUPTED +# +# Emitted when a disk image is being marked corrupt +# +# @device: device name +# +# @msg: informative message for human consumption, such as the kind of +# corruption being detected +# +# @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: 1.7 +## +{ 'event': 'BLOCK_IMAGE_CORRUPTED', + 'data': { 'device' : 'str', + 'msg' : 'str', + '*offset': 'int', + '*size' : 'int' } } + +## # @BLOCK_IO_ERROR # # Emitted when a disk I/O error occurs