On 14.07.2016 15:28, Kevin Wolf wrote: > 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 <kw...@redhat.com> > --- > blockdev.c | 14 +++----------- > qapi/block-core.json | 5 +++-- > qmp-commands.hx | 3 ++- > tests/qemu-iotests/041 | 8 +++----- > 4 files changed, 11 insertions(+), 19 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index b89b5f8..2d38537 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -3467,7 +3467,6 @@ void qmp_drive_mirror(bool has_job_id, const char > *job_id, const char *device, > Error **errp) > { > BlockDriverState *bs; > - BlockBackend *blk; > BlockDriverState *source, *target_bs; > AioContext *aio_context; > BlockMirrorBackingMode backing_mode; > @@ -3476,21 +3475,14 @@ void qmp_drive_mirror(bool has_job_id, const char > *job_id, const char *device, > int flags; > int64_t size; > > - blk = blk_by_name(device); > - if (!blk) { > - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > - "Device '%s' not found", device); > + bs = qmp_get_root_bs(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, device); > - goto out; > - } > - bs = blk_bs(blk); > if (!has_mode) { > mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; > }
After this, bs->drv may be used. So I think we should keep a bdrv_is_inserted() or bs->drv check here. Max
signature.asc
Description: OpenPGP digital signature