thebeanogamer / rpms / qemu-kvm

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