From patchwork Thu Jun 19 19:39:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 361990 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 65856140096 for ; Fri, 20 Jun 2014 05:55:10 +1000 (EST) Received: from localhost ([::1]:37614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiQO-0002Jc-5r for incoming@patchwork.ozlabs.org; Thu, 19 Jun 2014 15:55:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiCE-00054k-JW for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxiC8-0007uI-5x for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiC7-0007u2-Us for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:24 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeJJk009402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Jun 2014 15:40:19 -0400 Received: from localhost (ovpn-113-20.phx2.redhat.com [10.3.113.20]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeI8E002398; Thu, 19 Jun 2014 15:40:18 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 19 Jun 2014 15:39:45 -0400 Message-Id: <1403206792-15387-34-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> References: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 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 33/40] qapi event: convert QUORUM events 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/quorum.c | 25 ++++++++----------------- docs/qmp/qmp-events.txt | 41 ----------------------------------------- monitor.c | 6 +++--- qapi-event.json | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 61 deletions(-) delete mode 100644 docs/qmp/qmp-events.txt diff --git a/block/quorum.c b/block/quorum.c index 426077a..86802d3 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -17,6 +17,7 @@ #include #include "block/block_int.h" #include "qapi/qmp/qjson.h" +#include "qapi-event.h" #define HASH_LENGTH 32 @@ -198,32 +199,22 @@ static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s, static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret) { - QObject *data; - assert(node_name); - data = qobject_from_jsonf("{ 'node-name': %s" - ", 'sector-num': %" PRId64 - ", 'sectors-count': %d }", - node_name, acb->sector_num, acb->nb_sectors); + const char *msg = NULL; if (ret < 0) { - QDict *dict = qobject_to_qdict(data); - qdict_put(dict, "error", qstring_from_str(strerror(-ret))); + msg = strerror(-ret); } - monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data); - qobject_decref(data); + qapi_event_send_quorum_report_bad(!!msg, msg, node_name, + acb->sector_num, acb->nb_sectors, &error_abort); } static void quorum_report_failure(QuorumAIOCB *acb) { - QObject *data; const char *reference = acb->common.bs->device_name[0] ? acb->common.bs->device_name : acb->common.bs->node_name; - data = qobject_from_jsonf("{ 'reference': %s" - ", 'sector-num': %" PRId64 - ", 'sectors-count': %d }", - reference, acb->sector_num, acb->nb_sectors); - monitor_protocol_event(QEVENT_QUORUM_FAILURE, data); - qobject_decref(data); + + qapi_event_send_quorum_failure(reference, acb->sector_num, + acb->nb_sectors, &error_abort); } static int quorum_vote_error(QuorumAIOCB *acb); diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt deleted file mode 100644 index adf45d3..0000000 --- a/docs/qmp/qmp-events.txt +++ /dev/null @@ -1,41 +0,0 @@ - QEMU Machine Protocol Events - ============================ - -QUORUM_FAILURE --------------- - -Emitted by the Quorum block driver if it fails to establish a quorum. - -Data: - -- "reference": device name if defined else node name. -- "sector-num": Number of the first sector of the failed read operation. -- "sector-count": Failed read operation sector count. - -Example: - -{ "event": "QUORUM_FAILURE", - "data": { "reference": "usr1", "sector-num": 345435, "sector-count": 5 }, - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } - -QUORUM_REPORT_BAD ------------------ - -Emitted to report a corruption of a Quorum file. - -Data: - -- "error": Error message (json-string, optional) - Only present on failure. This field contains a human-readable - error message. There are no semantics other than that the - block layer reported an error and clients should not try to - interpret the error string. -- "node-name": The graph node name of the block driver state. -- "sector-num": Number of the first sector of the failed read operation. -- "sector-count": Failed read operation sector count. - -Example: - -{ "event": "QUORUM_REPORT_BAD", - "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } diff --git a/monitor.c b/monitor.c index e82f75e..db154e0 100644 --- a/monitor.c +++ b/monitor.c @@ -617,6 +617,9 @@ static void monitor_qapi_event_init(void) monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000); monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000); monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000); + /* limit the rate of quorum events to avoid hammering the management */ + monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000); + monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000); qmp_event_set_func_emit(monitor_qapi_event_queue); } @@ -743,9 +746,6 @@ monitor_protocol_event_throttle(MonitorEvent event, * and initialize state */ static void monitor_protocol_event_init(void) { - /* limit the rate of quorum events to avoid hammering the management */ - monitor_protocol_event_throttle(QEVENT_QUORUM_REPORT_BAD, 1000); - monitor_protocol_event_throttle(QEVENT_QUORUM_FAILURE, 1000); } /** diff --git a/qapi-event.json b/qapi-event.json index d07da39..fbdda48 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -266,3 +266,41 @@ ## { 'event': 'GUEST_PANICKED', 'data': { 'action': 'GuestPanicAction' } } + +## +# @QUORUM_FAILURE +# +# Emitted by the Quorum block driver if it fails to establish a quorum +# +# @reference: device name if defined else node name +# +# @sector-num: number of the first sector of the failed read operation +# +# @sector-count: failed read operation sector count +# +# Since: 2.0 +## +{ 'event': 'QUORUM_FAILURE', + 'data': { 'reference': 'str', 'sector-num': 'int', 'sector-count': 'int' } } + +## +# @QUORUM_REPORT_BAD +# +# Emitted to report a corruption of a Quorum file +# +# @error: #optional, error message. Only present on failure. This field +# contains a human-readable error message. There are no semantics other +# than that the block layer reported an error and clients should not +# try to interpret the error string. +# +# @node-name: the graph node name of the block driver state +# +# @sector-num: number of the first sector of the failed read operation +# +# @sector-count: failed read operation sector count +# +# Since: 2.0 +## +{ 'event': 'QUORUM_REPORT_BAD', + 'data': { '*error': 'str', 'node-name': 'str', + 'sector-num': 'int', 'sector-count': 'int' } }