thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-iotests-026-Test-EIO-on-allocation-in-a-data-file.patch

be904d
From d8776fd50df7bb5cddfc94126356f8b5084f5344 Mon Sep 17 00:00:00 2001
be904d
From: Max Reitz <mreitz@redhat.com>
be904d
Date: Mon, 13 Jul 2020 14:24:50 -0400
be904d
Subject: [PATCH 3/4] iotests/026: Test EIO on allocation in a data-file
be904d
be904d
RH-Author: Max Reitz <mreitz@redhat.com>
be904d
Message-id: <20200713142451.289703-4-mreitz@redhat.com>
be904d
Patchwork-id: 97955
be904d
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 3/4] iotests/026: Test EIO on allocation in a data-file
be904d
Bugzilla: 1807057
be904d
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
be904d
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
be904d
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
be904d
be904d
Test what happens when writing data to an external data file, where the
be904d
write requires an L2 entry to be allocated, but the data write fails.
be904d
be904d
Signed-off-by: Max Reitz <mreitz@redhat.com>
be904d
Message-Id: <20200225143130.111267-4-mreitz@redhat.com>
be904d
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
be904d
(cherry picked from commit 81311255f217859413c94f2cd9cebf2684bbda94)
be904d
Signed-off-by: Max Reitz <mreitz@redhat.com>
be904d
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
be904d
---
be904d
 tests/qemu-iotests/026             | 32 ++++++++++++++++++++++++++++++
be904d
 tests/qemu-iotests/026.out         |  6 ++++++
be904d
 tests/qemu-iotests/026.out.nocache |  6 ++++++
be904d
 3 files changed, 44 insertions(+)
be904d
be904d
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
be904d
index d89729697f..c1c96a41d9 100755
be904d
--- a/tests/qemu-iotests/026
be904d
+++ b/tests/qemu-iotests/026
be904d
@@ -30,6 +30,7 @@ _cleanup()
be904d
 {
be904d
 	_cleanup_test_img
be904d
     rm "$TEST_DIR/blkdebug.conf"
be904d
+    rm -f "$TEST_IMG.data_file"
be904d
 }
be904d
 trap "_cleanup; exit \$status" 0 1 2 3 15
be904d
 
be904d
@@ -236,6 +237,37 @@ $QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io
be904d
 
be904d
 _check_test_img
be904d
 
be904d
+echo
be904d
+echo === Avoid freeing external data clusters on failure ===
be904d
+echo
be904d
+
be904d
+# Similar test as the last one, except we test what happens when there
be904d
+# is an error when writing to an external data file instead of when
be904d
+# writing to a preallocated zero cluster
be904d
+_make_test_img -o "data_file=$TEST_IMG.data_file" $CLUSTER_SIZE
be904d
+
be904d
+# Put blkdebug above the data-file, and a raw node on top of that so
be904d
+# that blkdebug will see a write_aio event and emit an error
be904d
+$QEMU_IO -c "write 0 $CLUSTER_SIZE" \
be904d
+    "json:{
be904d
+         'driver': 'qcow2',
be904d
+         'file': { 'driver': 'file', 'filename': '$TEST_IMG' },
be904d
+         'data-file': {
be904d
+             'driver': 'raw',
be904d
+             'file': {
be904d
+                 'driver': 'blkdebug',
be904d
+                 'config': '$TEST_DIR/blkdebug.conf',
be904d
+                 'image': {
be904d
+                     'driver': 'file',
be904d
+                     'filename': '$TEST_IMG.data_file'
be904d
+                 }
be904d
+             }
be904d
+         }
be904d
+     }" \
be904d
+    | _filter_qemu_io
be904d
+
be904d
+_check_test_img
be904d
+
be904d
 # success, all done
be904d
 echo "*** done"
be904d
 rm -f $seq.full
be904d
diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out
be904d
index 83989996ff..c1b3b58482 100644
be904d
--- a/tests/qemu-iotests/026.out
be904d
+++ b/tests/qemu-iotests/026.out
be904d
@@ -653,4 +653,10 @@ wrote 1024/1024 bytes at offset 0
be904d
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
be904d
 write failed: Input/output error
be904d
 No errors were found on the image.
be904d
+
be904d
+=== Avoid freeing external data clusters on failure ===
be904d
+
be904d
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
be904d
+write failed: Input/output error
be904d
+No errors were found on the image.
be904d
 *** done
be904d
diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache
be904d
index 9359d26d7e..8d5001648a 100644
be904d
--- a/tests/qemu-iotests/026.out.nocache
be904d
+++ b/tests/qemu-iotests/026.out.nocache
be904d
@@ -661,4 +661,10 @@ wrote 1024/1024 bytes at offset 0
be904d
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
be904d
 write failed: Input/output error
be904d
 No errors were found on the image.
be904d
+
be904d
+=== Avoid freeing external data clusters on failure ===
be904d
+
be904d
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
be904d
+write failed: Input/output error
be904d
+No errors were found on the image.
be904d
 *** done
be904d
-- 
be904d
2.27.0
be904d