]> Git Repo - qemu.git/commitdiff
block: Fix is_allocated_above with resized files
authorVishvananda Ishaya <[email protected]>
Thu, 24 Jan 2013 18:02:08 +0000 (10:02 -0800)
committerStefan Hajnoczi <[email protected]>
Fri, 1 Feb 2013 13:58:28 +0000 (14:58 +0100)
In an image chain, if the base image is smaller than the current
image, we need to make sure to use the current images count of
unallocated blocks once we get to the end of the base image. Without
this change the code will return 0 blocks when it gets to the end
of the base image and mirror_run will fail its assertion.

Signed-off-by: Vishvananda Ishaya <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
block.c

diff --git a/block.c b/block.c
index ba67c0def2eac8cd745e2e6334d8ba64a4f9aa46..50dab8e595fad860c1b524614864320d6adef5eb 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2800,7 +2800,9 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
          *
          * [sector_num+x, nr_sectors] allocated.
          */
-        if (n > pnum_inter) {
+        if (n > pnum_inter &&
+            (intermediate == top ||
+             sector_num + pnum_inter < intermediate->total_sectors)) {
             n = pnum_inter;
         }
 
This page took 0.035893 seconds and 4 git commands to generate.