aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c4
-rw-r--r--block/snapshot.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/block.c b/block.c
index 39f373e035..9694018a68 100644
--- a/block.c
+++ b/block.c
@@ -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;
}
diff --git a/block/snapshot.c b/block/snapshot.c
index f9903bc94e..3218a542df 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -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;