From 67a51a2fa1212326602dac399027ca94e382a7f2 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Wed, 20 Nov 2013 09:16:44 +0100 Subject: [PATCH 05/14] block: Round up total_sectors RH-Author: Fam Zheng Message-id: <1384939004-30831-3-git-send-email-famz@redhat.com> Patchwork-id: 55785 O-Subject: [RHEL-7 qemu-kvm PATCH 2/2] block: Round up total_sectors Bugzilla: 1025138 RH-Acked-by: Paolo Bonzini RH-Acked-by: Kevin Wolf RH-Acked-by: Stefan Hajnoczi Since b94a2610, bdrv_getlength() is omitted when probing image. VMDK monolithicFlat is broken by that because a file < 512 bytes can't be read with its total_sectors truncated to 0. This patch round up the size to BDRV_SECTOR_SIZE, when a image size is not sector aligned. Signed-off-by: Fam Zheng Reviewed-by: Benoit Canet Signed-off-by: Stefan Hajnoczi (cherry picked from commit 7e382003f1bd9d8a441ecc5ac8a74bad3564d943) Signed-off-by: Fam Zheng --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Miroslav Rezanina Signed-off-by: Fam Zheng --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Miroslav Rezanina --- block.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 301c4fb..72ab36c 100644 --- a/block.c +++ b/block.c @@ -612,7 +612,7 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint) if (length < 0) { return length; } - hint = length >> BDRV_SECTOR_BITS; + hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE); } bs->total_sectors = hint; -- 1.7.1