mirror of https://github.com/xemu-project/xemu.git
qapi event: convert DEVICE_TRAY_MOVED
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
24b699fb2b
commit
a5ee7bd454
21
block.c
21
block.c
|
@ -35,6 +35,7 @@
|
||||||
#include "block/qapi.h"
|
#include "block/qapi.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
#include "qemu/timer.h"
|
#include "qemu/timer.h"
|
||||||
|
#include "qapi-event.h"
|
||||||
|
|
||||||
#ifdef CONFIG_BSD
|
#ifdef CONFIG_BSD
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -2162,17 +2163,6 @@ void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv,
|
||||||
qobject_decref(data);
|
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)
|
static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)
|
||||||
{
|
{
|
||||||
if (bs->dev_ops && bs->dev_ops->change_media_cb) {
|
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);
|
bs->dev_ops->change_media_cb(bs->dev_opaque, load);
|
||||||
if (tray_was_closed) {
|
if (tray_was_closed) {
|
||||||
/* tray open */
|
/* tray open */
|
||||||
bdrv_emit_qmp_eject_event(bs, true);
|
qapi_event_send_device_tray_moved(bdrv_get_device_name(bs),
|
||||||
|
true, &error_abort);
|
||||||
}
|
}
|
||||||
if (load) {
|
if (load) {
|
||||||
/* tray close */
|
/* tray close */
|
||||||
bdrv_emit_qmp_eject_event(bs, false);
|
qapi_event_send_device_tray_moved(bdrv_get_device_name(bs),
|
||||||
|
false, &error_abort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5217,7 +5209,8 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs->device_name[0] != '\0') {
|
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, &error_abort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,24 +168,6 @@ Example:
|
||||||
Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR
|
Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR
|
||||||
event.
|
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
|
GUEST_PANICKED
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
|
@ -164,3 +164,17 @@
|
||||||
##
|
##
|
||||||
{ 'command': 'nbd-server-stop' }
|
{ 'command': 'nbd-server-stop' }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @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: 1.1
|
||||||
|
##
|
||||||
|
{ 'event': 'DEVICE_TRAY_MOVED',
|
||||||
|
'data': { 'device': 'str', 'tray-open': 'bool' } }
|
||||||
|
|
Loading…
Reference in New Issue