When doing a block mirror to a target that does not support zero init (e.g. host device and raw format), unallocated sectors on the source may lead to a corrupted target image.
Unallocated sectors are skipped over during block mirror (the dirty bitmap is only loaded with allocated sectors), so whatever data is already present on the target device in those sectors will likely still be there, leading the guest to read invalid data. There are 3 patches in this series: Patch 1 allows block device dirty bitmaps to be created but not attached (i.e. placed in the dirty_bitmaps list) to a BDS. This clears the way to having a bitmap to be used to track unallocated sectors above the 'base' image. Patch 2 splits out the mirror code that invokes mirror_iteration(), so that we can in later patches run it multiple times using different bitmaps. Patch 3 introduces a 2-pass mirror streaming approach, whereas the first pass writes zeroes for unallocated source sectors (if appropriate for the image type), and the second pass writes the actual source data. Jeff Cody (3): block: allow creation of detached dirty bitmaps block: mirror - split out part of mirror_run() block: mirror - zero unallocated target sectors when zero init not present block.c | 26 +++- block/mirror.c | 302 ++++++++++++++++++++++++++++------------------ blockdev.c | 4 +- include/block/block.h | 1 + include/block/block_int.h | 3 +- migration/block.c | 2 +- qapi/block-core.json | 6 +- 7 files changed, 214 insertions(+), 130 deletions(-) -- 1.9.3