From 63ba17d39f1a8d262b31ea6a07dd3eb45d5a41e2 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 24 Jan 2013 10:02:08 -0800 Subject: [PATCH] block: Fix is_allocated_above with resized files 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 Signed-off-by: Stefan Hajnoczi --- block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index ba67c0def..50dab8e59 100644 --- 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; } -- 2.39.5