cryptospore / rpms / qemu-kvm

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