diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-06-23 14:20:24 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-09-05 19:06:47 +0200 |
commit | 0524e93a3fd7bff5bb4a584c372f2632ab7c0e0f (patch) | |
tree | 819da417768425c21b050edfdf41db97e4bb00e0 /blockdev.c | |
parent | b7e4fa224200ec87b9599a1d72b16ada35a3d113 (diff) |
block: Accept node-name for drive-mirror
In order to remove the necessity to use BlockBackend names in the
external API, we want to allow node-names everywhere. This converts
drive-mirror to accept a node-name without lifting the restriction that
we're operating at a root node.
In case of an invalid device name, the command returns the GenericError
error class now instead of DeviceNotFound, because this is what
qmp_get_root_bs() returns.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/blockdev.c b/blockdev.c index 773336c1c3..a392e08ed2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3429,7 +3429,6 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, void qmp_drive_mirror(DriveMirror *arg, Error **errp) { BlockDriverState *bs; - BlockBackend *blk; BlockDriverState *source, *target_bs; AioContext *aio_context; BlockMirrorBackingMode backing_mode; @@ -3439,21 +3438,14 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) int64_t size; const char *format = arg->format; - blk = blk_by_name(arg->device); - if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", arg->device); + bs = qmp_get_root_bs(arg->device, errp); + if (!bs) { return; } - aio_context = blk_get_aio_context(blk); + aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (!blk_is_available(blk)) { - error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, arg->device); - goto out; - } - bs = blk_bs(blk); if (!arg->has_mode) { arg->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } |