yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests-026-Move-v3-exclusive-test-to-new-file.patch

8fced6
From a4a984e67e276e643b8a51f39ca426d0967754a0 Mon Sep 17 00:00:00 2001
8fced6
From: Max Reitz <mreitz@redhat.com>
8fced6
Date: Mon, 13 Jul 2020 14:24:51 -0400
8fced6
Subject: [PATCH 4/4] iotests/026: Move v3-exclusive test to new file
8fced6
MIME-Version: 1.0
8fced6
Content-Type: text/plain; charset=UTF-8
8fced6
Content-Transfer-Encoding: 8bit
8fced6
8fced6
RH-Author: Max Reitz <mreitz@redhat.com>
8fced6
Message-id: <20200713142451.289703-5-mreitz@redhat.com>
8fced6
Patchwork-id: 97956
8fced6
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 4/4] iotests/026: Move v3-exclusive test to new file
8fced6
Bugzilla: 1807057
8fced6
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
8fced6
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
8fced6
8fced6
data_file does not work with v2, and we probably want 026 to keep
8fced6
working for v2 images.  Thus, open a new file for v3-exclusive error
8fced6
path test cases.
8fced6
8fced6
Fixes: 81311255f217859413c94f2cd9cebf2684bbda94
8fced6
       (“iotests/026: Test EIO on allocation in a data-file”)
8fced6
Signed-off-by: Max Reitz <mreitz@redhat.com>
8fced6
Message-Id: <20200311140707.1243218-1-mreitz@redhat.com>
8fced6
Reviewed-by: John Snow <jsnow@redhat.com>
8fced6
Tested-by: John Snow <jsnow@redhat.com>
8fced6
Signed-off-by: Max Reitz <mreitz@redhat.com>
8fced6
(cherry picked from commit c264e5d2f9f5d73977eac8e5d084f727b3d07ea9)
8fced6
8fced6
Conflicts:
8fced6
      tests/qemu-iotests/group
8fced6
      - As per usual.
8fced6
8fced6
Signed-off-by: Max Reitz <mreitz@redhat.com>
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 tests/qemu-iotests/026             | 31 -----------
8fced6
 tests/qemu-iotests/026.out         |  6 --
8fced6
 tests/qemu-iotests/026.out.nocache |  6 --
8fced6
 tests/qemu-iotests/289             | 89 ++++++++++++++++++++++++++++++
8fced6
 tests/qemu-iotests/289.out         |  8 +++
8fced6
 tests/qemu-iotests/group           |  1 +
8fced6
 6 files changed, 98 insertions(+), 43 deletions(-)
8fced6
 create mode 100755 tests/qemu-iotests/289
8fced6
 create mode 100644 tests/qemu-iotests/289.out
8fced6
8fced6
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
8fced6
index c1c96a41d9..3afd708863 100755
8fced6
--- a/tests/qemu-iotests/026
8fced6
+++ b/tests/qemu-iotests/026
8fced6
@@ -237,37 +237,6 @@ $QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io
8fced6
 
8fced6
 _check_test_img
8fced6
 
8fced6
-echo
8fced6
-echo === Avoid freeing external data clusters on failure ===
8fced6
-echo
8fced6
-
8fced6
-# Similar test as the last one, except we test what happens when there
8fced6
-# is an error when writing to an external data file instead of when
8fced6
-# writing to a preallocated zero cluster
8fced6
-_make_test_img -o "data_file=$TEST_IMG.data_file" $CLUSTER_SIZE
8fced6
-
8fced6
-# Put blkdebug above the data-file, and a raw node on top of that so
8fced6
-# that blkdebug will see a write_aio event and emit an error
8fced6
-$QEMU_IO -c "write 0 $CLUSTER_SIZE" \
8fced6
-    "json:{
8fced6
-         'driver': 'qcow2',
8fced6
-         'file': { 'driver': 'file', 'filename': '$TEST_IMG' },
8fced6
-         'data-file': {
8fced6
-             'driver': 'raw',
8fced6
-             'file': {
8fced6
-                 'driver': 'blkdebug',
8fced6
-                 'config': '$TEST_DIR/blkdebug.conf',
8fced6
-                 'image': {
8fced6
-                     'driver': 'file',
8fced6
-                     'filename': '$TEST_IMG.data_file'
8fced6
-                 }
8fced6
-             }
8fced6
-         }
8fced6
-     }" \
8fced6
-    | _filter_qemu_io
8fced6
-
8fced6
-_check_test_img
8fced6
-
8fced6
 # success, all done
8fced6
 echo "*** done"
8fced6
 rm -f $seq.full
8fced6
diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out
8fced6
index c1b3b58482..83989996ff 100644
8fced6
--- a/tests/qemu-iotests/026.out
8fced6
+++ b/tests/qemu-iotests/026.out
8fced6
@@ -653,10 +653,4 @@ wrote 1024/1024 bytes at offset 0
8fced6
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
8fced6
 write failed: Input/output error
8fced6
 No errors were found on the image.
8fced6
-
8fced6
-=== Avoid freeing external data clusters on failure ===
8fced6
-
8fced6
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
8fced6
-write failed: Input/output error
8fced6
-No errors were found on the image.
8fced6
 *** done
8fced6
diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache
8fced6
index 8d5001648a..9359d26d7e 100644
8fced6
--- a/tests/qemu-iotests/026.out.nocache
8fced6
+++ b/tests/qemu-iotests/026.out.nocache
8fced6
@@ -661,10 +661,4 @@ wrote 1024/1024 bytes at offset 0
8fced6
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
8fced6
 write failed: Input/output error
8fced6
 No errors were found on the image.
8fced6
-
8fced6
-=== Avoid freeing external data clusters on failure ===
8fced6
-
8fced6
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
8fced6
-write failed: Input/output error
8fced6
-No errors were found on the image.
8fced6
 *** done
8fced6
diff --git a/tests/qemu-iotests/289 b/tests/qemu-iotests/289
8fced6
new file mode 100755
8fced6
index 0000000000..1c11d4030e
8fced6
--- /dev/null
8fced6
+++ b/tests/qemu-iotests/289
8fced6
@@ -0,0 +1,89 @@
8fced6
+#!/usr/bin/env bash
8fced6
+#
8fced6
+# qcow2 v3-exclusive error path testing
8fced6
+# (026 tests paths common to v2 and v3)
8fced6
+#
8fced6
+# Copyright (C) 2020 Red Hat, Inc.
8fced6
+#
8fced6
+# This program is free software; you can redistribute it and/or modify
8fced6
+# it under the terms of the GNU General Public License as published by
8fced6
+# the Free Software Foundation; either version 2 of the License, or
8fced6
+# (at your option) any later version.
8fced6
+#
8fced6
+# This program is distributed in the hope that it will be useful,
8fced6
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
8fced6
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8fced6
+# GNU General Public License for more details.
8fced6
+#
8fced6
+# You should have received a copy of the GNU General Public License
8fced6
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
8fced6
+#
8fced6
+
8fced6
+seq=$(basename $0)
8fced6
+echo "QA output created by $seq"
8fced6
+
8fced6
+status=1	# failure is the default!
8fced6
+
8fced6
+_cleanup()
8fced6
+{
8fced6
+    _cleanup_test_img
8fced6
+    rm "$TEST_DIR/blkdebug.conf"
8fced6
+    rm -f "$TEST_IMG.data_file"
8fced6
+}
8fced6
+trap "_cleanup; exit \$status" 0 1 2 3 15
8fced6
+
8fced6
+# get standard environment, filters and checks
8fced6
+. ./common.rc
8fced6
+. ./common.filter
8fced6
+. ./common.pattern
8fced6
+
8fced6
+_supported_fmt qcow2
8fced6
+_supported_proto file
8fced6
+# This is a v3-exclusive test;
8fced6
+# As for data_file, error paths often very much depend on whether
8fced6
+# there is an external data file or not; so we create one exactly when
8fced6
+# we want to test it
8fced6
+_unsupported_imgopts 'compat=0.10' data_file
8fced6
+
8fced6
+echo
8fced6
+echo === Avoid freeing external data clusters on failure ===
8fced6
+echo
8fced6
+
8fced6
+cat > "$TEST_DIR/blkdebug.conf" <
8fced6
+[inject-error]
8fced6
+event = "write_aio"
8fced6
+errno = "5"
8fced6
+once = "on"
8fced6
+EOF
8fced6
+
8fced6
+# Test what happens when there is an error when writing to an external
8fced6
+# data file instead of when writing to a preallocated zero cluster
8fced6
+_make_test_img -o "data_file=$TEST_IMG.data_file" 64k
8fced6
+
8fced6
+# Put blkdebug above the data-file, and a raw node on top of that so
8fced6
+# that blkdebug will see a write_aio event and emit an error.  This
8fced6
+# will then trigger the alloc abort code, which we want to test here.
8fced6
+$QEMU_IO -c "write 0 64k" \
8fced6
+    "json:{
8fced6
+         'driver': 'qcow2',
8fced6
+         'file': { 'driver': 'file', 'filename': '$TEST_IMG' },
8fced6
+         'data-file': {
8fced6
+             'driver': 'raw',
8fced6
+             'file': {
8fced6
+                 'driver': 'blkdebug',
8fced6
+                 'config': '$TEST_DIR/blkdebug.conf',
8fced6
+                 'image': {
8fced6
+                     'driver': 'file',
8fced6
+                     'filename': '$TEST_IMG.data_file'
8fced6
+                 }
8fced6
+             }
8fced6
+         }
8fced6
+     }" \
8fced6
+    | _filter_qemu_io
8fced6
+
8fced6
+_check_test_img
8fced6
+
8fced6
+# success, all done
8fced6
+echo "*** done"
8fced6
+rm -f $seq.full
8fced6
+status=0
8fced6
diff --git a/tests/qemu-iotests/289.out b/tests/qemu-iotests/289.out
8fced6
new file mode 100644
8fced6
index 0000000000..e54e2629d4
8fced6
--- /dev/null
8fced6
+++ b/tests/qemu-iotests/289.out
8fced6
@@ -0,0 +1,8 @@
8fced6
+QA output created by 289
8fced6
+
8fced6
+=== Avoid freeing external data clusters on failure ===
8fced6
+
8fced6
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 data_file=TEST_DIR/t.IMGFMT.data_file
8fced6
+write failed: Input/output error
8fced6
+No errors were found on the image.
8fced6
+*** done
8fced6
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
8fced6
index cddae00ded..07ce9c2249 100644
8fced6
--- a/tests/qemu-iotests/group
8fced6
+++ b/tests/qemu-iotests/group
8fced6
@@ -291,4 +291,5 @@
8fced6
 280 rw migration quick
8fced6
 281 rw quick
8fced6
 284 rw
8fced6
+289 rw quick
8fced6
 291 rw quick
8fced6
-- 
8fced6
2.27.0
8fced6