Hi, See the previous cover letter for the reason for patches 6 through 9: https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg00563.html
But no only some bdrv_has_zero_init() implementations are wrong, some callers also use it the wrong way. First, qemu-img and mirror use it for pre-existing images, where it doesn’t have any meaning. Both should consider pre-existing images to always be non-zero and not look at bdrv_has-zero_init() (patches 1, 2, and the tests in 10 and 11). Second, vhdx and parallels call bdrv_has_zero_init() when they do not really care about an image’s post-create state but only about what happens when you grow an image. That is a bit ugly, and also overly safe when growing preallocated images without preallocating the new areas. So this series adds a new function bdrv_has_zero_init_truncate() that is more suited to vhdx's and parallel's needs (patches 3 through 5). v2: - Simplified preallocation checks in qcow2 and vhdx [Kevin] - Added patches 1 – 5, 10, 11 git-backport-diff against v1: Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively 001/11:[down] 'qemu-img: Fix bdrv_has_zero_init() use in convert' 002/11:[down] 'mirror: Fix bdrv_has_zero_init() use' 003/11:[down] 'block: Add bdrv_has_zero_init_truncate()' 004/11:[down] 'block: Implement .bdrv_has_zero_init_truncate()' 005/11:[down] 'block: Use bdrv_has_zero_init_truncate()' 006/11:[0077] [FC] 'qcow2: Fix .bdrv_has_zero_init()' 007/11:[----] [--] 'vdi: Fix .bdrv_has_zero_init()' 008/11:[0021] [FC] 'vhdx: Fix .bdrv_has_zero_init()' 009/11:[----] [--] 'iotests: Convert to preallocated encrypted qcow2' 010/11:[down] 'iotests: Test convert -n to pre-filled image' 011/11:[down] 'iotests: Full mirror to existing non-zero image' Max Reitz (11): qemu-img: Fix bdrv_has_zero_init() use in convert mirror: Fix bdrv_has_zero_init() use block: Add bdrv_has_zero_init_truncate() block: Implement .bdrv_has_zero_init_truncate() block: Use bdrv_has_zero_init_truncate() qcow2: Fix .bdrv_has_zero_init() vdi: Fix .bdrv_has_zero_init() vhdx: Fix .bdrv_has_zero_init() iotests: Convert to preallocated encrypted qcow2 iotests: Test convert -n to pre-filled image iotests: Full mirror to existing non-zero image include/block/block.h | 1 + include/block/block_int.h | 9 ++++++ block.c | 21 +++++++++++++ block/file-posix.c | 1 + block/file-win32.c | 1 + block/gluster.c | 4 +++ block/mirror.c | 11 +++++-- block/nfs.c | 1 + block/parallels.c | 2 +- block/qcow2.c | 30 +++++++++++++++++- block/qed.c | 1 + block/raw-format.c | 6 ++++ block/rbd.c | 1 + block/sheepdog.c | 1 + block/ssh.c | 1 + block/vdi.c | 13 +++++++- block/vhdx.c | 28 +++++++++++++++-- blockdev.c | 16 ++++++++-- qemu-img.c | 11 +++++-- tests/test-block-iothread.c | 2 +- tests/qemu-iotests/041 | 62 ++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/041.out | 4 +-- tests/qemu-iotests/122 | 17 ++++++++++ tests/qemu-iotests/122.out | 8 +++++ tests/qemu-iotests/188 | 20 +++++++++++- tests/qemu-iotests/188.out | 4 +++ 26 files changed, 254 insertions(+), 22 deletions(-) -- 2.21.0