From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkL-0001te-EI for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsWkC-0001xF-2L for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:17 -0400 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]:40299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsWkB-0001x5-S0 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 08:26:08 -0400 Received: by mail-pd0-f181.google.com with SMTP id z10so1021167pdj.40 for ; Thu, 05 Jun 2014 05:26:07 -0700 (PDT) From: Wenchao Xia Date: Thu, 5 Jun 2014 05:22:14 -0700 Message-Id: <1401970944-18735-20-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 19/29] qapi event: convert DEVICE_TRAY_MOVED 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.c | 21 +++++++-------------- docs/qmp/qmp-events.txt | 18 ------------------ qapi-event.json | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/block.c b/block.c index 84ad945..52f4580 100644 --- a/block.c +++ b/block.c @@ -35,6 +35,7 @@ #include "block/qapi.h" #include "qmp-commands.h" #include "qemu/timer.h" +#include "qapi-event.h" #ifdef CONFIG_BSD #include @@ -2162,17 +2163,6 @@ void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, qobject_decref(data); } -static void bdrv_emit_qmp_eject_event(BlockDriverState *bs, bool ejected) -{ - QObject *data; - - data = qobject_from_jsonf("{ 'device': %s, 'tray-open': %i }", - bdrv_get_device_name(bs), ejected); - monitor_protocol_event(QEVENT_DEVICE_TRAY_MOVED, 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) { @@ -2180,11 +2170,13 @@ static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) bs->dev_ops->change_media_cb(bs->dev_opaque, load); if (tray_was_closed) { /* tray open */ - bdrv_emit_qmp_eject_event(bs, true); + qapi_event_send_device_tray_moved(bdrv_get_device_name(bs), + true, NULL); } if (load) { /* tray close */ - bdrv_emit_qmp_eject_event(bs, false); + qapi_event_send_device_tray_moved(bdrv_get_device_name(bs), + false, NULL); } } } @@ -5173,7 +5165,8 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag) } if (bs->device_name[0] != '\0') { - bdrv_emit_qmp_eject_event(bs, eject_flag); + qapi_event_send_device_tray_moved(bdrv_get_device_name(bs), + eject_flag, NULL); } } diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index fda68df..1ee6f53 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -158,24 +158,6 @@ Example: Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR event. -DEVICE_TRAY_MOVED ------------------ - -It's emitted whenever the tray of a removable device is moved by the guest -or by HMP/QMP commands. - -Data: - -- "device": device name (json-string) -- "tray-open": true if the tray has been opened or false if it has been closed - (json-bool) - -{ "event": "DEVICE_TRAY_MOVED", - "data": { "device": "ide1-cd0", - "tray-open": true - }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - GUEST_PANICKED -------------- diff --git a/qapi-event.json b/qapi-event.json index fc83fed..c2c65f9 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -122,3 +122,18 @@ ## { 'event': 'DEVICE_DELETED', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @DEVICE_TRAY_MOVED +# +# Emitted whenever the tray of a removable device is moved by the guest or by +# HMP/QMP commands +# +# @device: device name +# +# @tray-open: true if the tray has been opened or false if it has been closed +# +# Since: 2.1 +## +{ 'event': 'DEVICE_TRAY_MOVED', + 'data': { 'device': 'str', 'tray-open': 'bool' } } -- 1.7.1