vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted

Instead of bdrv_getlength().

Commit 57322b7 did this all over block, but one more bdrv_getlength()
has crept in since.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2014-08-21 14:36:19 +02:00 committed by Kevin Wolf
parent cbf95a0b11
commit 0a156f7c75

View File

@ -397,7 +397,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
{ {
VmdkExtent *extent; VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque; BDRVVmdkState *s = bs->opaque;
int64_t length; int64_t nb_sectors;
if (cluster_sectors > 0x200000) { if (cluster_sectors > 0x200000) {
/* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */ /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs,
return -EFBIG; return -EFBIG;
} }
length = bdrv_getlength(file); nb_sectors = bdrv_nb_sectors(file);
if (length < 0) { if (nb_sectors < 0) {
return length; return nb_sectors;
} }
s->extents = g_renew(VmdkExtent, s->extents, s->num_extents + 1); s->extents = g_renew(VmdkExtent, s->extents, s->num_extents + 1);
@ -432,8 +432,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
extent->l1_entry_sectors = l2_size * cluster_sectors; extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size; extent->l2_size = l2_size;
extent->cluster_sectors = flat ? sectors : cluster_sectors; extent->cluster_sectors = flat ? sectors : cluster_sectors;
extent->next_cluster_sector = extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors);
ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
if (s->num_extents > 1) { if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;