mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-18 23:52:14 -06:00
block: fully delete bs->file when closing
We are reusing bs->file across close/open, which may not cause any known bugs but is a recipe for trouble. Prefer bdrv_delete, and enjoy the new invariant in the implementation of bdrv_delete. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
a275fa42fa
commit
0ac9377d04
1 changed files with 2 additions and 4 deletions
6
block.c
6
block.c
|
@ -882,7 +882,8 @@ void bdrv_close(BlockDriverState *bs)
|
||||||
bs->backing_format[0] = '\0';
|
bs->backing_format[0] = '\0';
|
||||||
|
|
||||||
if (bs->file != NULL) {
|
if (bs->file != NULL) {
|
||||||
bdrv_close(bs->file);
|
bdrv_delete(bs->file);
|
||||||
|
bs->file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdrv_dev_change_media_cb(bs, false);
|
bdrv_dev_change_media_cb(bs, false);
|
||||||
|
@ -1062,9 +1063,6 @@ void bdrv_delete(BlockDriverState *bs)
|
||||||
bdrv_make_anon(bs);
|
bdrv_make_anon(bs);
|
||||||
|
|
||||||
bdrv_close(bs);
|
bdrv_close(bs);
|
||||||
if (bs->file != NULL) {
|
|
||||||
bdrv_delete(bs->file);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(bs != bs_snapshots);
|
assert(bs != bs_snapshots);
|
||||||
g_free(bs);
|
g_free(bs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue