qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/3] block: Add blk_new_with_bs() helper


From: Max Reitz
Subject: Re: [PATCH v2 1/3] block: Add blk_new_with_bs() helper
Date: Fri, 24 Apr 2020 11:53:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

On 24.04.20 00:17, Eric Blake wrote:
> There are several callers that need to create a new block backend from
> an existing BDS; make the task slightly easier with a common helper
> routine.
> 
> Suggested-by: Max Reitz <address@hidden>
> Signed-off-by: Eric Blake <address@hidden>
> ---
>  include/sysemu/block-backend.h |  2 ++
>  block/block-backend.c          | 23 +++++++++++++++++++++++
>  block/crypto.c                 |  8 +++-----
>  block/parallels.c              |  7 +++----
>  block/qcow.c                   |  7 +++----
>  block/qcow2.c                  | 15 ++++++---------
>  block/qed.c                    |  7 +++----
>  block/sheepdog.c               |  9 ++++-----
>  block/vdi.c                    |  7 +++----
>  block/vhdx.c                   |  7 +++----
>  block/vmdk.c                   |  9 ++++-----
>  block/vpc.c                    |  7 +++----
>  blockdev.c                     |  8 +++-----
>  blockjob.c                     |  7 ++-----
>  14 files changed, 65 insertions(+), 58 deletions(-)

Reviewed-by: Max Reitz <address@hidden>

> diff --git a/blockdev.c b/blockdev.c
> index 5faddaa7052f..f43426ed5fbc 100644
> --- a/blockdev.c
> +++ b/blockdev.c

[...]

> @@ -2734,14 +2733,13 @@ void qmp_block_resize(bool has_device, const char 
> *device,
>          goto out;
>      }
> 
> -    blk = blk_new(bdrv_get_aio_context(bs), BLK_PERM_RESIZE, BLK_PERM_ALL);
> -    ret = blk_insert_bs(blk, bs, errp);
> -    if (ret < 0) {
> +    blk = blk_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp);
> +    if (!blk) {
>          goto out;
>      }
> 
>      bdrv_drained_begin(bs);
> -    ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp);
> +    blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp);

This is also addressed by
https://lists.nongnu.org/archive/html/qemu-devel/2020-04/msg03656.html,
but it does make sense to fix it here, too.  Well, whichever lands first
lands first, I suppose (so @ret can be dropped).

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]