yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests-229-Use-blkdebug-to-inject-an-error.patch

ddf19c
From 104c8f6210bf573cf39c2a14cdb0b081baaaa3f0 Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Wed, 3 Jun 2020 16:03:23 +0100
ddf19c
Subject: [PATCH 24/26] iotests/229: Use blkdebug to inject an error
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200603160325.67506-10-kwolf@redhat.com>
ddf19c
Patchwork-id: 97108
ddf19c
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 09/11] iotests/229: Use blkdebug to inject an error
ddf19c
Bugzilla: 1778593
ddf19c
RH-Acked-by: Eric Blake <eblake@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
ddf19c
ddf19c
229 relies on the mirror running into an I/O error when the target is
ddf19c
smaller than the source. After changing mirror to catch this condition
ddf19c
while starting the job, this test case won't get a job that is paused
ddf19c
for an I/O error any more. Use blkdebug instead to inject an error.
ddf19c
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Reviewed-by: Eric Blake <eblake@redhat.com>
ddf19c
Message-Id: <20200511135825.219437-3-kwolf@redhat.com>
ddf19c
Reviewed-by: Max Reitz <mreitz@redhat.com>
ddf19c
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit d89ac3cf305b28c024a76805a84d75c0ee1e786f)
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 tests/qemu-iotests/229     | 18 +++++++++++++-----
ddf19c
 tests/qemu-iotests/229.out |  6 +++---
ddf19c
 2 files changed, 16 insertions(+), 8 deletions(-)
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229
ddf19c
index e18a464..511fbc0 100755
ddf19c
--- a/tests/qemu-iotests/229
ddf19c
+++ b/tests/qemu-iotests/229
ddf19c
@@ -32,6 +32,7 @@ _cleanup()
ddf19c
     _cleanup_qemu
ddf19c
     _cleanup_test_img
ddf19c
     rm -f "$TEST_IMG" "$DEST_IMG"
ddf19c
+    rm -f "$TEST_DIR/blkdebug.conf"
ddf19c
 }
ddf19c
 trap "_cleanup; exit \$status" 0 1 2 3 15
ddf19c
 
ddf19c
@@ -48,11 +49,10 @@ _supported_os Linux
ddf19c
 
ddf19c
 DEST_IMG="$TEST_DIR/d.$IMGFMT"
ddf19c
 TEST_IMG="$TEST_DIR/b.$IMGFMT"
ddf19c
+BLKDEBUG_CONF="$TEST_DIR/blkdebug.conf"
ddf19c
 
ddf19c
 _make_test_img 2M
ddf19c
-
ddf19c
-# destination for mirror will be too small, causing error
ddf19c
-TEST_IMG=$DEST_IMG _make_test_img 1M
ddf19c
+TEST_IMG=$DEST_IMG _make_test_img 2M
ddf19c
 
ddf19c
 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
ddf19c
 
ddf19c
@@ -66,11 +66,18 @@ echo
ddf19c
 echo '=== Starting drive-mirror, causing error & stop  ==='
ddf19c
 echo
ddf19c
 
ddf19c
+cat > "$BLKDEBUG_CONF" <
ddf19c
+[inject-error]
ddf19c
+event = "write_aio"
ddf19c
+errno = "5"
ddf19c
+once = "on"
ddf19c
+EOF
ddf19c
+
ddf19c
 _send_qemu_cmd $QEMU_HANDLE \
ddf19c
     "{'execute': 'drive-mirror',
ddf19c
                  'arguments': {'device': 'testdisk',
ddf19c
                                'format': '$IMGFMT',
ddf19c
-                               'target': '$DEST_IMG',
ddf19c
+                               'target': 'blkdebug:$BLKDEBUG_CONF:$DEST_IMG',
ddf19c
                                'sync':   'full',
ddf19c
                                'mode':   'existing',
ddf19c
                                'on-source-error': 'stop',
ddf19c
@@ -89,7 +96,8 @@ success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
ddf19c
                  'arguments': { 'device': 'testdisk',
ddf19c
                                 'force': true}}" \
ddf19c
      "BLOCK_JOB_CANCELLED" "Assertion" \
ddf19c
-    | grep -v '"BLOCK_JOB_ERROR"'
ddf19c
+    | grep -v '"BLOCK_JOB_ERROR"' \
ddf19c
+    | _filter_block_job_offset
ddf19c
 
ddf19c
 # success, all done
ddf19c
 echo "*** done"
ddf19c
diff --git a/tests/qemu-iotests/229.out b/tests/qemu-iotests/229.out
ddf19c
index 22350d7..4de6dfa 100644
ddf19c
--- a/tests/qemu-iotests/229.out
ddf19c
+++ b/tests/qemu-iotests/229.out
ddf19c
@@ -1,6 +1,6 @@
ddf19c
 QA output created by 229
ddf19c
 Formatting 'TEST_DIR/b.IMGFMT', fmt=IMGFMT size=2097152
ddf19c
-Formatting 'TEST_DIR/d.IMGFMT', fmt=IMGFMT size=1048576
ddf19c
+Formatting 'TEST_DIR/d.IMGFMT', fmt=IMGFMT size=2097152
ddf19c
 wrote 2097152/2097152 bytes at offset 0
ddf19c
 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ddf19c
 {'execute': 'qmp_capabilities'}
ddf19c
@@ -8,7 +8,7 @@ wrote 2097152/2097152 bytes at offset 0
ddf19c
 
ddf19c
 === Starting drive-mirror, causing error & stop  ===
ddf19c
 
ddf19c
-{'execute': 'drive-mirror', 'arguments': {'device': 'testdisk', 'format': 'IMGFMT', 'target': 'TEST_DIR/d.IMGFMT', 'sync': 'full', 'mode': 'existing', 'on-source-error': 'stop', 'on-target-error': 'stop' }}
ddf19c
+{'execute': 'drive-mirror', 'arguments': {'device': 'testdisk', 'format': 'IMGFMT', 'target': 'blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/d.IMGFMT', 'sync': 'full', 'mode': 'existing', 'on-source-error': 'stop', 'on-target-error': 'stop' }}
ddf19c
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "testdisk"}}
ddf19c
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}}
ddf19c
 {"return": {}}
ddf19c
@@ -21,5 +21,5 @@ wrote 2097152/2097152 bytes at offset 0
ddf19c
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}}
ddf19c
 {"return": {}}
ddf19c
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "testdisk"}}
ddf19c
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "testdisk", "len": 2097152, "offset": 1048576, "speed": 0, "type": "mirror"}}
ddf19c
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "testdisk", "len": 2097152, "offset": OFFSET, "speed": 0, "type": "mirror"}}
ddf19c
 *** done
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c