On 11.05.20 17:29, Kevin Wolf wrote: > Am 11.05.2020 um 17:08 hat Max Reitz geschrieben: >> On 11.05.20 15:58, Kevin Wolf wrote: >>> This patch makes the raw image the same size as the file in a different >>> format that is mirrored as raw to it to avoid errors when mirror starts >>> to enforce that source and target are the same size. >>> >>> We check only that the first 512 bytes are zeroed (instead of 64k) >>> because some image formats create image files that are smaller than 64k, >>> so trying to read 64k would result in I/O errors. Apart from this, 512 >>> is more appropriate anyway because the raw format driver protects >>> specifically the first 512 bytes. >>> >>> Signed-off-by: Kevin Wolf <kw...@redhat.com> >>> --- >>> tests/qemu-iotests/109 | 10 ++--- >>> tests/qemu-iotests/109.out | 74 +++++++++++++------------------- >>> tests/qemu-iotests/common.filter | 5 +++ >>> 3 files changed, 41 insertions(+), 48 deletions(-) >>> >>> diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 >>> index 5bc2e9b001..3ffeaf3c55 100755 >>> --- a/tests/qemu-iotests/109 >>> +++ b/tests/qemu-iotests/109 >>> @@ -77,14 +77,14 @@ for fmt in qcow qcow2 qed vdi vmdk vpc; do >>> echo "=== Writing a $fmt header into raw ===" >>> echo >>> >>> - _make_test_img 64M >>> TEST_IMG="$TEST_IMG.src" IMGFMT=$fmt _make_test_img 64M >>> + _make_test_img $(du -b "$TEST_IMG.src" | cut -f1) | >>> _filter_img_create_size >> >> Why du and not the file length (stat -c '%s')? > > Because the test from which I copied had 'du' and the internet claimed > that 'stat -c' isn't portable. Now I see that we do use it in other test > cases, so I guess it would have been fine, too. Is there a good reason > why 'stat' would be better?
Oh, I didn’t know that du -b reports the file length. Well, then that works, too. (I’ve never seen du used for anything but getting the, well, disk usage.) (I figured -b would just report the size in bytes.) Then: Reviewed-by: Max Reitz <mre...@redhat.com>
signature.asc
Description: OpenPGP digital signature