yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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