Blame SOURCES/kvm-iotests-Add-case-for-a-corrupted-inactive-image.patch

1bdc94
From e9dd4092392c53954bbd394e4286f3ac431f47aa Mon Sep 17 00:00:00 2001
1bdc94
From: Max Reitz <mreitz@redhat.com>
1bdc94
Date: Mon, 18 Jun 2018 18:00:55 +0200
1bdc94
Subject: [PATCH 49/54] iotests: Add case for a corrupted inactive image
1bdc94
1bdc94
RH-Author: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: <20180618180055.22739-4-mreitz@redhat.com>
1bdc94
Patchwork-id: 80794
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 3/3] iotests: Add case for a corrupted inactive image
1bdc94
Bugzilla: 1588039
1bdc94
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
1bdc94
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
RH-Acked-by: John Snow <jsnow@redhat.com>
1bdc94
1bdc94
Reviewed-by: John Snow <jsnow@redhat.com>
1bdc94
Tested-by: Jeff Cody <jcody@redhat.com>
1bdc94
Reviewed-by: Jeff Cody <jcody@redhat.com>
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: 20180606193702.7113-4-mreitz@redhat.com
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
(cherry picked from commit c50abd175a88cd41c2c08339de91f6f6e4a7b162)
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 tests/qemu-iotests/060     | 30 ++++++++++++++++++++++++++++++
1bdc94
 tests/qemu-iotests/060.out | 14 ++++++++++++++
1bdc94
 2 files changed, 44 insertions(+)
1bdc94
1bdc94
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
1bdc94
index 6c7407f..7bdf609 100755
1bdc94
--- a/tests/qemu-iotests/060
1bdc94
+++ b/tests/qemu-iotests/060
1bdc94
@@ -440,6 +440,36 @@ echo "{'execute': 'qmp_capabilities'}
1bdc94
             -drive if=none,node-name=drive,file="$TEST_IMG",driver=qcow2 \
1bdc94
     | _filter_qmp | _filter_qemu_io
1bdc94
 
1bdc94
+echo
1bdc94
+echo "=== Testing incoming inactive corrupted image ==="
1bdc94
+echo
1bdc94
+
1bdc94
+_make_test_img 64M
1bdc94
+# Create an unaligned L1 entry, so qemu will signal a corruption when
1bdc94
+# reading from the covered area
1bdc94
+poke_file "$TEST_IMG" "$l1_offset" "\x00\x00\x00\x00\x2a\x2a\x2a\x2a"
1bdc94
+
1bdc94
+# Inactive images are effectively read-only images, so this should be a
1bdc94
+# non-fatal corruption (which does not modify the image)
1bdc94
+echo "{'execute': 'qmp_capabilities'}
1bdc94
+      {'execute': 'human-monitor-command',
1bdc94
+       'arguments': {'command-line': 'qemu-io drive \"read 0 512\"'}}
1bdc94
+      {'execute': 'quit'}" \
1bdc94
+    | $QEMU -qmp stdio -nographic -nodefaults \
1bdc94
+            -blockdev "{'node-name': 'drive',
1bdc94
+                        'driver': 'qcow2',
1bdc94
+                        'file': {
1bdc94
+                            'driver': 'file',
1bdc94
+                            'filename': '$TEST_IMG'
1bdc94
+                        }}" \
1bdc94
+            -incoming exec:'cat /dev/null' \
1bdc94
+            2>&1 \
1bdc94
+    | _filter_qmp | _filter_qemu_io
1bdc94
+
1bdc94
+echo
1bdc94
+# Image should not have been marked corrupt
1bdc94
+_img_info --format-specific | grep 'corrupt:'
1bdc94
+
1bdc94
 # success, all done
1bdc94
 echo "*** done"
1bdc94
 rm -f $seq.full
1bdc94
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
1bdc94
index 25d5c39..99234fb 100644
1bdc94
--- a/tests/qemu-iotests/060.out
1bdc94
+++ b/tests/qemu-iotests/060.out
1bdc94
@@ -420,4 +420,18 @@ write failed: Input/output error
1bdc94
 {"return": ""}
1bdc94
 {"return": {}}
1bdc94
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
1bdc94
+
1bdc94
+=== Testing incoming inactive corrupted image ===
1bdc94
+
1bdc94
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
1bdc94
+QMP_VERSION
1bdc94
+{"return": {}}
1bdc94
+qcow2: Image is corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); further non-fatal corruption events will be suppressed
1bdc94
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "", "msg": "L2 table offset 0x2a2a2a00 unaligned (L1 index: 0)", "node-name": "drive", "fatal": false}}
1bdc94
+read failed: Input/output error
1bdc94
+{"return": ""}
1bdc94
+{"return": {}}
1bdc94
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
1bdc94
+
1bdc94
+    corrupt: false
1bdc94
 *** done
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94