Skip to content

Commit

Permalink
block: make .bdrv_close optional
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and kevmw committed Aug 15, 2018
1 parent 8d65a3c commit 3c00529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion block.c
Original file line number Diff line number Diff line change
Expand Up @@ -3349,7 +3349,9 @@ static void bdrv_close(BlockDriverState *bs)
bdrv_drain(bs); /* in case flush left pending I/O */

if (bs->drv) {
bs->drv->bdrv_close(bs);
if (bs->drv->bdrv_close) {
bs->drv->bdrv_close(bs);
}
bs->drv = NULL;
}

Expand Down
4 changes: 3 additions & 1 deletion block/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
qobject_unref(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));

drv->bdrv_close(bs);
if (drv->bdrv_close) {
drv->bdrv_close(bs);
}
bdrv_unref_child(bs, bs->file);
bs->file = NULL;

Expand Down

0 comments on commit 3c00529

Please sign in to comment.