mirror of https://github.com/xqemu/xqemu.git
blockdev: Add blockdev-close-tray
Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
7d8a9f71b9
commit
abaaf59d24
23
blockdev.c
23
blockdev.c
|
@ -2124,6 +2124,29 @@ void qmp_blockdev_open_tray(const char *device, bool has_force, bool force,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qmp_blockdev_close_tray(const char *device, Error **errp)
|
||||||
|
{
|
||||||
|
BlockBackend *blk;
|
||||||
|
|
||||||
|
blk = blk_by_name(device);
|
||||||
|
if (!blk) {
|
||||||
|
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||||
|
"Device '%s' not found", device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!blk_dev_has_removable_media(blk)) {
|
||||||
|
error_setg(errp, "Device '%s' is not removable", device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!blk_dev_is_tray_open(blk)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blk_dev_change_media_cb(blk, true);
|
||||||
|
}
|
||||||
|
|
||||||
/* throttling disk I/O limits */
|
/* throttling disk I/O limits */
|
||||||
void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
|
void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
|
||||||
int64_t bps_wr,
|
int64_t bps_wr,
|
||||||
|
|
|
@ -1908,6 +1908,22 @@
|
||||||
'data': { 'device': 'str',
|
'data': { 'device': 'str',
|
||||||
'*force': 'bool' } }
|
'*force': 'bool' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @blockdev-close-tray:
|
||||||
|
#
|
||||||
|
# Closes a block device's tray. If there is a block driver state tree associated
|
||||||
|
# with the block device (which is currently ejected), that tree will be loaded
|
||||||
|
# as the medium.
|
||||||
|
#
|
||||||
|
# If the tray was already closed before, this will be a no-op.
|
||||||
|
#
|
||||||
|
# @device: block device name
|
||||||
|
#
|
||||||
|
# Since: 2.5
|
||||||
|
##
|
||||||
|
{ 'command': 'blockdev-close-tray',
|
||||||
|
'data': { 'device': 'str' } }
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @BlockErrorAction
|
# @BlockErrorAction
|
||||||
|
|
|
@ -4000,6 +4000,41 @@ Example:
|
||||||
|
|
||||||
<- { "return": {} }
|
<- { "return": {} }
|
||||||
|
|
||||||
|
EQMP
|
||||||
|
|
||||||
|
{
|
||||||
|
.name = "blockdev-close-tray",
|
||||||
|
.args_type = "device:s",
|
||||||
|
.mhandler.cmd_new = qmp_marshal_blockdev_close_tray,
|
||||||
|
},
|
||||||
|
|
||||||
|
SQMP
|
||||||
|
blockdev-close-tray
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Closes a block device's tray. If there is a block driver state tree associated
|
||||||
|
with the block device (which is currently ejected), that tree will be loaded as
|
||||||
|
the medium.
|
||||||
|
|
||||||
|
If the tray was already closed before, this will be a no-op.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
- "device": block device name (json-string)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
-> { "execute": "blockdev-close-tray",
|
||||||
|
"arguments": { "device": "ide1-cd0" } }
|
||||||
|
|
||||||
|
<- { "timestamp": { "seconds": 1418751345,
|
||||||
|
"microseconds": 272147 },
|
||||||
|
"event": "DEVICE_TRAY_MOVED",
|
||||||
|
"data": { "device": "ide1-cd0",
|
||||||
|
"tray-open": false } }
|
||||||
|
|
||||||
|
<- { "return": {} }
|
||||||
|
|
||||||
EQMP
|
EQMP
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue