diff options
author | Max Reitz <mreitz@redhat.com> | 2015-10-26 21:39:09 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-11-11 16:22:47 +0100 |
commit | abaaf59d245b6984644497b6745f88912c715c39 (patch) | |
tree | 203c4b635ec5ab0d27fe44f6d0767df2d5bcdddc /blockdev.c | |
parent | 7d8a9f71b9ec9fa295265392218efaf0771d96e0 (diff) | |
download | qemu-abaaf59d245b6984644497b6745f88912c715c39.tar.gz qemu-abaaf59d245b6984644497b6745f88912c715c39.tar.bz2 qemu-abaaf59d245b6984644497b6745f88912c715c39.zip |
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>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index d01a99e9cf..cb8a2f095b 100644 --- a/blockdev.c +++ b/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 */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, |