On 24.04.20 11:53, Max Reitz wrote: > 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 >> Signed-off-by: Eric Blake >> --- >> 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 (With the Patchew warning fixed, of course (i.e., we should set ret to -EPERM or something in qcow.c)) >> 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). I intended to affix the “(so @ret can be dropped)” to the first sentence, not the second one... Max