diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-10-07 13:59:24 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-10-20 14:03:50 +0200 |
commit | 6007cdd448b6729e82530e85579e5089ddc58eba (patch) | |
tree | f4b1495e2e76072ec28f197efe2f98e8eece4173 | |
parent | d829a2115f0817993e2b683601cb544a27980a8f (diff) |
blockdev: Convert qmp_eject(), qmp_change_blockdev() to BlockBackend
Much more command code needs conversion. I'm converting these now
because they're using bdrv_dev_* functions, which I'm about to lift
into BlockBackend.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | blockdev.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/blockdev.c b/blockdev.c index 2a3d908320..a32d84c673 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1593,8 +1593,10 @@ exit: } -static void eject_device(BlockDriverState *bs, int force, Error **errp) +static void eject_device(BlockBackend *blk, int force, Error **errp) { + BlockDriverState *bs = blk_bs(blk); + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { return; } @@ -1618,15 +1620,15 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp) void qmp_eject(const char *device, bool has_force, bool force, Error **errp) { - BlockDriverState *bs; + BlockBackend *blk; - bs = bdrv_find(device); - if (!bs) { + blk = blk_by_name(device); + if (!blk) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } - eject_device(bs, force, errp); + eject_device(blk, force, errp); } void qmp_block_passwd(bool has_device, const char *device, @@ -1685,16 +1687,18 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, void qmp_change_blockdev(const char *device, const char *filename, const char *format, Error **errp) { + BlockBackend *blk; BlockDriverState *bs; BlockDriver *drv = NULL; int bdrv_flags; Error *err = NULL; - bs = bdrv_find(device); - if (!bs) { + blk = blk_by_name(device); + if (!blk) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } + bs = blk_bs(blk); if (format) { drv = bdrv_find_whitelisted_format(format, bs->read_only); @@ -1704,7 +1708,7 @@ void qmp_change_blockdev(const char *device, const char *filename, } } - eject_device(bs, 0, &err); + eject_device(blk, 0, &err); if (err) { error_propagate(errp, err); return; |