05bba0
From f65ef16bd01c14e252e262ec24ff3ac16e0e335d Mon Sep 17 00:00:00 2001
05bba0
From: Max Reitz <mreitz@redhat.com>
05bba0
Date: Sat, 13 Jun 2015 16:21:59 +0200
05bba0
Subject: [PATCH 05/42] iotests: Add test for image header overlap
05bba0
05bba0
Message-id: <1434212556-3927-6-git-send-email-mreitz@redhat.com>
05bba0
Patchwork-id: 66024
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 05/42] iotests: Add test for image header overlap
05bba0
Bugzilla: 1129893
05bba0
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
05bba0
RH-Acked-by: Fam Zheng <famz@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
05bba0
BZ: 1129893
05bba0
05bba0
Add a test for an image with an unallocated image header; instead of an
05bba0
assertion, this should result in the image being marked corrupt.
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Reviewed-by: Eric Blake <eblake@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
(cherry picked from commit a42f8a3d05c5598cee893c9cf5ffeee48bacb83e)
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 tests/qemu-iotests/060     | 9 +++++++++
05bba0
 tests/qemu-iotests/060.out | 8 ++++++++
05bba0
 2 files changed, 17 insertions(+)
05bba0
05bba0
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
05bba0
index 2abd566..5180e23 100644
05bba0
--- a/tests/qemu-iotests/060
05bba0
+++ b/tests/qemu-iotests/060
05bba0
@@ -164,6 +164,15 @@ wait_break 0
05bba0
 write 64k 64k
05bba0
 resume 0" | $QEMU_IO | _filter_qemu_io
05bba0
 
05bba0
+echo
05bba0
+echo "=== Testing unallocated image header ==="
05bba0
+echo
05bba0
+_make_test_img 64M
05bba0
+# Create L1/L2
05bba0
+$QEMU_IO -c "$OPEN_RW" -c "write 0 64k" | _filter_qemu_io
05bba0
+poke_file "$TEST_IMG" "$rb_offset" "\x00\x00"
05bba0
+$QEMU_IO -c "$OPEN_RW" -c "write 64k 64k" | _filter_qemu_io
05bba0
+
05bba0
 # success, all done
05bba0
 echo "*** done"
05bba0
 rm -f $seq.full
05bba0
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
05bba0
index a517948..c27c952 100644
05bba0
--- a/tests/qemu-iotests/060.out
05bba0
+++ b/tests/qemu-iotests/060.out
05bba0
@@ -93,4 +93,12 @@ blkdebug: Suspended request '0'
05bba0
 write failed: Input/output error
05bba0
 blkdebug: Resuming request '0'
05bba0
 aio_write failed: No medium found
05bba0
+
05bba0
+=== Testing unallocated image header ===
05bba0
+
05bba0
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
05bba0
+wrote 65536/65536 bytes at offset 0
05bba0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
05bba0
+qcow2: Preventing invalid write on metadata (overlaps with qcow2_header); image marked as corrupt.
05bba0
+write failed: Input/output error
05bba0
 *** done
05bba0
-- 
05bba0
1.8.3.1
05bba0