summaryrefslogtreecommitdiff
path: root/block/vdi.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-08-22 12:57:51 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-08-22 13:37:35 +0200
commite5164735e5b674a10134894589a060a0f5f32ccc (patch)
tree7fc7bff17b3c7831c126da8b144165c3b00137ad /block/vdi.c
parentad5bc00194a981af3435835b5ceb5d624a98caf7 (diff)
downloadqemu-e5164735e5b674a10134894589a060a0f5f32ccc.tar.gz
block: do not directly set total_sectors
To prepare for expressing block sizes in bytes instead of sector counts, this patch replaces all direct assignments of bs->total_sectors. This converts the expression `bs->total_sectors = X` (where X is sector count) to `bdrv_setlength(bs, BDRV_SECTOR_SIZE * X)`. Expressions such as `bs->total_sectors = Y / 512` are changed to `bdrv_setlength(bs, BDRV_SECTOR_SIZE * (Y / 512))` to account for the floor division change. If these conditions can be relaxed, it will be done in the future. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'block/vdi.c')
-rw-r--r--block/vdi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/vdi.c b/block/vdi.c
index 4b10aacc3b..8086510edd 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -467,7 +467,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- bs->total_sectors = header.disk_size / SECTOR_SIZE;
+ bdrv_setlength(bs, BDRV_SECTOR_SIZE * (header.disk_size / SECTOR_SIZE));
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;