summaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index f9e045ff2b..8854d96279 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -689,7 +689,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
s->l2_size = 1 << s->l2_bits;
- bs->total_sectors = header.size / 512;
+ bdrv_setlength(bs, BDRV_SECTOR_SIZE * (header.size / 512));
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
@@ -2254,7 +2254,7 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
/* bdrv_co_do_writev will have increased the total_sectors value to include
* the VM state - the VM state is however not an actual part of the block
* device, therefore, we need to restore the old value. */
- bs->total_sectors = total_sectors;
+ bdrv_setlength(bs, BDRV_SECTOR_SIZE * total_sectors);
return ret;
}