Using -S 0 is supposed to allocate everything in the output image; or at least it is supposed to always explicitly write zeros even if the area in question is known to only contain zeros. That doesn't always work right now, so this series fixes it (patch 1, to be specific).
I only noticed after I had written the test added by patch 4 that we already had an -S 0 test case which is included in the iotest 122. However, the test added here works for all image formats and is maybe more of a direct test (instead of querying the format whether it thinks it allocated all of the data we directly ask du whether everything has been allocated) so maybe it reflects better what users expect -S 0 to do. Maybe. Patches 2 and 3 are required for the test. I could have written the test without doing a convert with null-co as the source, but that would have been boring, so I did not. If you want to argue that in light of the existence of test 122 the new test added here is unnecessary and we therefore do not need patches 2, 3 and 4, please go ahead. I won't put up too much of a fight. ** A note about dependencies: When applied to Kevin's block branch, patch 4 will conflict in the qemu-iotests/group file. I had to base it on master master because right now about a fourth of all iotests break for qcow2 (for me, at least) on the block branch. ** v2: - Patch 1: The additional state BLK_ZERO_DATA actually made things more complicated than they are without. Drop it. [Kevin] - Patch 2: Made reading zeros optional and used "zeroes" throughout the patch so the spelling confirms with the "detect-zeroes" option. [Eric] (I personally like "zeros" better so it differs from the 3rd p. sg. of "to zero".) - Patch 3: If read-zeroes is false, we shouldn't indicate the BDS to only return zero(e)s when read. - Patch 4: Moved test to 150, and now we need to set the read-zeroes option to true. git-backport-diff against v2: 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/4:[0025] [FC] 'qemu-img: Fix preallocation with -S 0 for convert' 002/4:[down] 'block/null-{co,aio}: Allow reading zeroes' ^^^^ Actually just a reworded commit title, but there are functional changes here 003/4:[0007] [FC] 'block/null-{co,aio}: Implement get_block_status()' 004/4:[0008] [FC] 'iotests: Test qemu-img convert -S 0 behavior' Max Reitz (4): qemu-img: Fix preallocation with -S 0 for convert block/null-{co,aio}: Allow reading zeroes block/null-{co,aio}: Implement get_block_status() iotests: Test qemu-img convert -S 0 behavior block/null.c | 42 ++++++++++++++++++ qemu-img.c | 26 ++++++----- tests/qemu-iotests/122.out | 6 +-- tests/qemu-iotests/150 | 105 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/150.out | 14 ++++++ tests/qemu-iotests/group | 1 + 6 files changed, 179 insertions(+), 15 deletions(-) create mode 100755 tests/qemu-iotests/150 create mode 100644 tests/qemu-iotests/150.out -- 2.7.4