Implement 'eject' by calling blockdev-open-tray and blockdev-remove-medium.
Signed-off-by: Max Reitz <mre...@redhat.com> Reviewed-by: Eric Blake <ebl...@redhat.com> --- blockdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index 1aea565..2fc201c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1928,15 +1928,15 @@ out: void qmp_eject(const char *device, bool has_force, bool force, Error **errp) { - BlockBackend *blk; + Error *local_err = NULL; - blk = blk_by_name(device); - if (!blk) { - error_set(errp, QERR_DEVICE_NOT_FOUND, device); + qmp_blockdev_open_tray(device, has_force, force, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } - eject_device(blk, force, errp); + qmp_blockdev_remove_medium(device, errp); } void qmp_block_passwd(bool has_device, const char *device, -- 2.4.1