[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 08/11] block: Accept node-name for drive-back
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v4 08/11] block: Accept node-name for drive-backup |
Date: |
Mon, 18 Jul 2016 16:24:20 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
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-backup and the corresponding transaction action 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 <address@hidden>
> ---
> blockdev.c | 36 +++++++++---------------------------
> qapi/block-core.json | 4 ++--
> qmp-commands.hx | 2 +-
> tests/qemu-iotests/055 | 7 ++-----
> 4 files changed, 14 insertions(+), 35 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 6b1f2f0..b89b5f8 100644
> --- a/blockdev.c
> +++ b/blockdev.c
[...]
> @@ -3203,24 +3195,14 @@ static void do_drive_backup(const char *job_id, const
> char *device,
> mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> }
>
> - 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);
>
> - /* Although backup_run has this check too, we need to use bs->drv below,
> so
> - * do an early check redundantly. */
This comment makes a good point, bs->drv may be NULL. I think you should
either call bdrv_is_inserted() or check bs->drv directly.
Max
> - if (!blk_is_available(blk)) {
> - error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
> - goto out;
> - }
> - bs = blk_bs(blk);
> -
> if (!has_format) {
> format = mode == NEW_IMAGE_MODE_EXISTING ? NULL :
> bs->drv->format_name;
> }
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v4 03/11] block: Accept node-name for blockdev-backup, (continued)
- [Qemu-devel] [PATCH v4 03/11] block: Accept node-name for blockdev-backup, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 05/11] block: Accept node-name for blockdev-snapshot-delete-internal-sync, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 07/11] block: Accept node-name for change-backing-file, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 08/11] block: Accept node-name for drive-backup, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 06/11] block: Accept node-name for blockdev-snapshot-internal-sync, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 01/11] block: Accept node-name for block-stream, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 09/11] block: Accept node-name for drive-mirror, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 10/11] nbd-server: Use a separate BlockBackend, Kevin Wolf, 2016/07/14
- [Qemu-devel] [PATCH v4 11/11] nbd-server: Allow node name for nbd-server-add, Kevin Wolf, 2016/07/14