[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 4/4] block: Use blk_make_empty() after commits
From: |
Max Reitz |
Subject: |
Re: [PATCH v2 4/4] block: Use blk_make_empty() after commits |
Date: |
Wed, 29 Apr 2020 16:17:00 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 29.04.20 16:11, Max Reitz wrote:
> bdrv_commit() already has a BlockBackend pointing to the BDS that we
> want to empty, it just has the wrong permissions.
>
> qemu-img commit has no BlockBackend pointing to the old backing file
> yet, but introducing one is simple.
>
> After this commit, bdrv_make_empty() is the only remaining caller of
> BlockDriver.bdrv_make_empty().
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/commit.c | 16 +++++++++-------
> qemu-img.c | 19 ++++++++++++++-----
> 2 files changed, 23 insertions(+), 12 deletions(-)
[...]
> diff --git a/qemu-img.c b/qemu-img.c
> index 7f52742ef2..77f3575538 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1065,11 +1065,20 @@ static int img_commit(int argc, char **argv)
> goto unref_backing;
> }
>
> - if (!drop && bs->drv->bdrv_make_empty) {
> - ret = bs->drv->bdrv_make_empty(bs);
> - if (ret) {
> - error_setg_errno(&local_err, -ret, "Could not empty %s",
> - filename);
> + if (!drop) {
> + BlockBackend *old_backing_blk;
> +
> + old_backing_blk = blk_new_with_bs(bs, BLK_PERM_WRITE, BLK_PERM_ALL,
> + &local_err);
> + if (!old_backing_blk) {
> + goto unref_backing;
> + }
> + ret = blk_make_empty(old_backing_blk, &local_err);
> + blk_unref(old_backing_blk);
> + if (ret == -ENOTSUP) {
> + error_free(local_err);
> + local_err = NULL;
> + } else if (ret < 0) {
> goto unref_backing;
> }
> }
This patch should also include a %s/Could not empty/Failed to empty/ on
tests/qemu-iotests/098.out...
Max
signature.asc
Description: OpenPGP digital signature
- [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, Max Reitz, 2020/04/29
- [PATCH v2 3/4] block: Add blk_make_empty(), Max Reitz, 2020/04/29
- [PATCH v2 1/4] block: Add bdrv_make_empty(), Max Reitz, 2020/04/29
- [PATCH v2 2/4] block: Use bdrv_make_empty() where possible, Max Reitz, 2020/04/29
- [PATCH v2 4/4] block: Use blk_make_empty() after commits, Max Reitz, 2020/04/29
- Re: [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, no-reply, 2020/04/29
- Re: [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, no-reply, 2020/04/29
- Re: [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, no-reply, 2020/04/29
- Re: [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, no-reply, 2020/04/29
- Re: [PATCH v2 0/4] block: Do not call BlockDriver.bdrv_make_empty() directly, no-reply, 2020/04/29