cryptospore / rpms / qemu-kvm

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