From 86683283a5bec80b99107447a48cf226c019519f Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 31 Jul 2014 16:03:43 -0500 Subject: [CHANGE 21/31] qemu-iotests: Backport 060 To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Kevin Wolf Message-id: <1406822631-6570-22-git-send-email-kwolf@redhat.com> Patchwork-id: 60382 O-Subject: [RHEL-6.6 qemu-kvm PATCH v3 21/29] qemu-iotests: Backport 060 Bugzilla: 1122410 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Jeffrey Cody RH-Acked-by: Max Reitz The tests can't be as extensive for RHEL 6 as it is for upstream for several reasons: * RHEL 6 doesn't have driver-specific runtime options, so we always get the default checks. The checks for inactive L2 tables are disabled, so the test must be removed. * RHEL 6 doesn't have break/resume functionality in blkdebug, so the test with overlapping COW doesn't work and must be removed. * RHEL 6 doesn't support qcow2 v3. Therefore the incompatible feature flag for corrupted images can't be set. It is expected that a corrupted image can be opened without an error on RHEL 6. Signed-off-by: Kevin Wolf Signed-off-by: jen --- tests/qemu-iotests/060 | 58 ++++------------------------------------- tests/qemu-iotests/060.out | 65 +++++----------------------------------------- 2 files changed, 11 insertions(+), 112 deletions(-) diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 3cffc12..441925e 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -49,9 +49,12 @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) l2_offset=262144 # 0x40000 (XXX: just an assumption) l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) -IMGOPTS="compat=1.1" +# RHEL 6 doesn't have qcow2 v3 support +#IMGOPTS="compat=1.1" + +#OPEN_RW="open -o overlap-check=all $TEST_IMG" +OPEN_RW="open $TEST_IMG" -OPEN_RW="open -o overlap-check=all $TEST_IMG" # Overlap checks are done before write operations only, therefore opening an # image read-only makes the overlap-check option irrelevant OPEN_RO="open -r $TEST_IMG" @@ -113,57 +116,6 @@ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features $QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features -echo -echo "=== Testing cluster data reference into inactive L2 table ===" -echo -_make_test_img 64M -$QEMU_IO -c "$OPEN_RW" -c "write -P 1 0 512" | _filter_qemu_io -$QEMU_IMG snapshot -c foo "$TEST_IMG" -$QEMU_IO -c "$OPEN_RW" -c "write -P 2 0 512" | _filter_qemu_io -# The inactive L2 table remains at its old offset -poke_file "$TEST_IMG" "$l2_offset_after_snapshot" \ - "\x80\x00\x00\x00\x00\x04\x00\x00" -_check_test_img -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features -$QEMU_IO -c "$OPEN_RW" -c "write -P 3 0 512" | _filter_qemu_io -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features -_check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features -$QEMU_IO -c "$OPEN_RW" -c "write -P 4 0 512" | _filter_qemu_io -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features - -# Check data -$QEMU_IO -c "$OPEN_RO" -c "read -P 4 0 512" | _filter_qemu_io -$QEMU_IMG snapshot -a foo "$TEST_IMG" -_check_test_img -$QEMU_IO -c "$OPEN_RO" -c "read -P 1 0 512" | _filter_qemu_io - -echo -echo "=== Testing overlap while COW is in flight ===" -echo -# compat=0.10 is required in order to make the following discard actually -# unallocate the sector rather than make it a zero sector - we want COW, after -# all. -IMGOPTS='compat=0.10' _make_test_img 1G -# Write two clusters, the second one enforces creation of an L2 table after -# the first data cluster. -$QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io -# Discard the first cluster. This cluster will soon enough be reallocated and -# used for COW. -$QEMU_IO -c 'discard 0k 64k' "$TEST_IMG" | _filter_qemu_io -# Now, corrupt the image by marking the second L2 table cluster as free. -poke_file "$TEST_IMG" '131084' "\x00\x00" # 0x2000c -# Start a write operation requiring COW on the image stopping it right before -# doing the read; then, trigger the corruption prevention by writing anything to -# any unallocated cluster, leading to an attempt to overwrite the second L2 -# table. Finally, resume the COW write and see it fail (but not crash). -echo "open -o file.driver=blkdebug $TEST_IMG -break cow_read 0 -aio_write 0k 1k -wait_break 0 -write 64k 64k -resume 0" | $QEMU_IO | _filter_qemu_io - # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index a517948..0345053 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -8,10 +8,11 @@ ERROR cluster 3 refcount=1 reference=3 1 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. incompatible_features 0x0 -qcow2: Preventing invalid write on metadata (overlaps with active L1 table); image marked as corrupt. +qcow2: Preventing invalid write on metadata (overlaps with active L1 table); please use qemu-img check -r. write failed: Input/output error -incompatible_features 0x2 -qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write +incompatible_features 0x0 +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -24,9 +25,9 @@ ERROR cluster 2 refcount=1 reference=2 2 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. incompatible_features 0x0 -qcow2: Preventing invalid write on metadata (overlaps with refcount block); image marked as corrupt. +qcow2: Preventing invalid write on metadata (overlaps with refcount block); please use qemu-img check -r. write failed: Input/output error -incompatible_features 0x2 +incompatible_features 0x0 Repairing refcount block 0 refcount=2 The following inconsistencies were found and repaired: @@ -39,58 +40,4 @@ incompatible_features 0x0 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) incompatible_features 0x0 - -=== Testing cluster data reference into inactive L2 table === - -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -wrote 512/512 bytes at offset 0 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 512/512 bytes at offset 0 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -ERROR cluster 4 refcount=1 reference=2 -Leaked cluster 9 refcount=1 reference=0 - -1 errors were found on the image. -Data may be corrupted, or further writes to the image may corrupt it. - -1 leaked clusters were found on the image. -This means waste of disk space, but no harm to data. -incompatible_features 0x0 -qcow2: Preventing invalid write on metadata (overlaps with inactive L2 table); image marked as corrupt. -write failed: Input/output error -incompatible_features 0x2 -Repairing cluster 4 refcount=1 reference=2 -Repairing cluster 9 refcount=1 reference=0 -Repairing OFLAG_COPIED data cluster: l2_entry=8000000000040000 refcount=2 -The following inconsistencies were found and repaired: - - 1 leaked clusters - 2 corruptions - -Double checking the fixed image now... -No errors were found on the image. -incompatible_features 0x0 -wrote 512/512 bytes at offset 0 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -incompatible_features 0x0 -read 512/512 bytes at offset 0 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -No errors were found on the image. -read 512/512 bytes at offset 0 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) - -=== Testing overlap while COW is in flight === - -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 -wrote 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 65536/65536 bytes at offset 536870912 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -discard 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qcow2: Preventing invalid write on metadata (overlaps with active L2 table); image marked as corrupt. -blkdebug: Suspended request '0' -write failed: Input/output error -blkdebug: Resuming request '0' -aio_write failed: No medium found *** done -- 1.9.3