summaryrefslogtreecommitdiff
path: root/block/snapshot.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-11-20 15:41:31 +0100
committerKevin Wolf <kwolf@redhat.com>2017-11-21 14:48:23 +0100
commit70a5afedd64c3f0d3b5feae6b40b30f3e8d13e4b (patch)
tree93fa81af7514d079f443df71c32a0afe93cb68ae /block/snapshot.c
parent2b624fe079ee7123797f6c685e714795665c0e01 (diff)
downloadqemu-70a5afedd64c3f0d3b5feae6b40b30f3e8d13e4b.tar.gz
block: Error out on load_vm with active dirty bitmaps
Loading a snapshot invalidates the bitmap. Just marking all blocks dirty is not a useful response in practice, instead the user needs to be aware that we switch to a completely different state. If they are okay with losing the dirty bitmap, they can just explicitly delete it. This effectively reverts commit 04dec3c3ae5. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'block/snapshot.c')
-rw-r--r--block/snapshot.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/block/snapshot.c b/block/snapshot.c
index 8585599579..8cb70dbad5 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -182,25 +182,16 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
{
BlockDriver *drv = bs->drv;
int ret, open_ret;
- int64_t len;
if (!drv) {
error_setg(errp, "Block driver is closed");
return -ENOMEDIUM;
}
- len = bdrv_getlength(bs);
- if (len < 0) {
- error_setg_errno(errp, -len, "Cannot get block device size");
- return len;
+ if (!QLIST_EMPTY(&bs->dirty_bitmaps)) {
+ error_setg(errp, "Device has active dirty bitmaps");
+ return -EBUSY;
}
- /* We should set all bits in all enabled dirty bitmaps, because dirty
- * bitmaps reflect active state of disk and snapshot switch operation
- * actually dirties active state.
- * TODO: It may make sense not to set all bits but analyze block status of
- * current state and destination snapshot and do not set bits corresponding
- * to both-zero or both-unallocated areas. */
- bdrv_set_dirty(bs, 0, len);
if (drv->bdrv_snapshot_goto) {
ret = drv->bdrv_snapshot_goto(bs, snapshot_id);