Skip to contentSkip to conversation

block: Fix is_allocated_above with resized files

PATCH Applied Vishvananda Ishaya 2 participants 2 messages Jan 24, 2013 – Jan 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
Fixes https://bugs.launchpad.net/qemu/+bug/1103868

 block.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block.c +3 -1
index 6fa7c90..6474d9e 100644
@@ -2831,7 +2831,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;
         }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · Vishvananda Ishaya

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.

Quoted 6 lines

---
Fixes https://bugs.launchpad.net/qemu/+bug/1103868

 block.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan