@@ -2641,7 +2641,7 @@ int bdrv_apply_snapshot(BlockDriverState *bs, const char *snapshot_id, uint64_t
return ret;
}
- ret = refresh_total_sectors(bs, snapshot_size);
+ ret = refresh_total_sectors(bs, snapshot_size >> BDRV_SECTOR_BITS);
bdrv_dirty_bitmap_truncate(bs);
if (bs->blk) {
blk_dev_resize_cb(bs->blk);
@@ -528,6 +528,14 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
goto fail;
}
+ /* write updated header.size */
+ uint64_t be_disk_size = cpu_to_be64(sn->disk_size);
+ ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, size),
+ &be_disk_size, sizeof(uint64_t));
+ if (ret < 0) {
+ goto fail;
+ }
+
/*
* Decrease refcount of clusters of current L1 table.
*