mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
block: Use blk_make_empty() after commits
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 <mreitz@redhat.com> Message-Id: <20200429141126.85159-5-mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [kwolf: Fixed up reference output for 098] Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
2b7bbdbdef
commit
2d97fde439
3 changed files with 27 additions and 16 deletions
|
@ -414,7 +414,9 @@ int bdrv_commit(BlockDriverState *bs)
|
|||
}
|
||||
|
||||
ctx = bdrv_get_aio_context(bs);
|
||||
src = blk_new(ctx, BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
|
||||
/* WRITE_UNCHANGED is required for bdrv_make_empty() */
|
||||
src = blk_new(ctx, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED,
|
||||
BLK_PERM_ALL);
|
||||
backing = blk_new(ctx, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||
|
||||
ret = blk_insert_bs(src, bs, &local_err);
|
||||
|
@ -492,14 +494,14 @@ int bdrv_commit(BlockDriverState *bs)
|
|||
}
|
||||
}
|
||||
|
||||
if (drv->bdrv_make_empty) {
|
||||
ret = drv->bdrv_make_empty(bs);
|
||||
if (ret < 0) {
|
||||
goto ro_cleanup;
|
||||
}
|
||||
blk_flush(src);
|
||||
ret = blk_make_empty(src, NULL);
|
||||
/* Ignore -ENOTSUP */
|
||||
if (ret < 0 && ret != -ENOTSUP) {
|
||||
goto ro_cleanup;
|
||||
}
|
||||
|
||||
blk_flush(src);
|
||||
|
||||
/*
|
||||
* Make sure all data we wrote to the backing device is actually
|
||||
* stable on disk.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue