[sheepdog] [PATCH v2 1/3] block: Add blk_new_with_bs() helper
Max Reitz
mreitz at redhat.com
Fri Apr 24 11:53:53 CEST 2020
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 <mreitz at redhat.com>
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
> 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 <mreitz at redhat.com>
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20200424/77e593bd/attachment.sig>
More information about the sheepdog
mailing list