From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJSH3-0003Tz-Ff for qemu-devel@nongnu.org; Fri, 28 Feb 2014 13:35:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJSGy-0005dt-4v for qemu-devel@nongnu.org; Fri, 28 Feb 2014 13:35:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJSGx-0005dm-T7 for qemu-devel@nongnu.org; Fri, 28 Feb 2014 13:35:00 -0500 From: Stefan Hajnoczi Date: Fri, 28 Feb 2014 19:33:39 +0100 Message-Id: <1393612423-26267-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1393612423-26267-1-git-send-email-stefanha@redhat.com> References: <1393612423-26267-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 5/9] qmp: Make Quorum error events more palatable. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Anthony Liguori From: Beno=C3=AEt Canet Insert quorum QMP events documentation alphabetically. Also change the "ret" errno value by an optional "error" being an strerro= r(-ret) in the QUORUM_REPORT_BAD qmp event. Signed-off-by: Benoit Canet Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- block/quorum.c | 9 ++++-- docs/qmp/qmp-events.txt | 75 ++++++++++++++++++++++++----------------= ------ tests/qemu-iotests/081.out | 2 +- 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 6c28239..bd997b7 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -200,11 +200,14 @@ static void quorum_report_bad(QuorumAIOCB *acb, cha= r *node_name, int ret) { QObject *data; assert(node_name); - data =3D qobject_from_jsonf("{ 'ret': %d" - ", 'node-name': %s" + data =3D qobject_from_jsonf("{ 'node-name': %s" ", 'sector-num': %" PRId64 ", 'sectors-count': %d }", - ret, node_name, acb->sector_num, acb->nb_s= ectors); + node_name, acb->sector_num, acb->nb_sector= s); + if (ret < 0) { + QDict *dict =3D qobject_to_qdict(data); + qdict_put(dict, "error", qstring_from_str(strerror(-ret))); + } monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data); qobject_decref(data); } diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 00f9515..145402e 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -225,6 +225,45 @@ Data: "timestamp": { "seconds": 1368697518, "microseconds": 326866 } } } =20 +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 operatio= n. +- "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 t= ry 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 operatio= n. +- "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 } } + RESET ----- =20 @@ -500,39 +539,3 @@ Example: =20 Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is followed respectively by the RESET, SHUTDOWN, or STOP 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 operatio= n. -- "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: - -- "ret": The IO return code. -- "node-name": The graph node name of the block driver state. -- "sector-num": Number of the first sector of the failed read operatio= n. -- "sector-count": Failed read operation sector count. - -Example: - -{ "event": "QUORUM_REPORT_BAD", - "data": { "ret": 0, "node-name": "1.raw", "sector-num": 345435, - "sector-count": 5 }, - "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out index 4fe2f95..84aeb0c 100644 --- a/tests/qemu-iotests/081.out +++ b/tests/qemu-iotests/081.out @@ -30,7 +30,7 @@ Testing: -drive file=3DTEST_DIR/2.IMGFMT,format=3DIMGFM= T,if=3Dnone,id=3Ddrive2 QMP_VERSION {"return": {}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "even= t": "QUORUM_REPORT_BAD", "data": {"node-name": "", "ret": 0, "sectors-cou= nt": 20480, "sector-num": 0}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "even= t": "QUORUM_REPORT_BAD", "data": {"node-name": "", "sectors-count": 20480= , "sector-num": 0}} read 10485760/10485760 bytes at offset 0 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} --=20 1.8.5.3