thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-iotests-Repairing-error-during-snapshot-deletion.patch

169b9a
From dd504cf4643e80d0b7afe16c82ac247a9e35a4af Mon Sep 17 00:00:00 2001
169b9a
From: Max Reitz <mreitz@redhat.com>
169b9a
Date: Mon, 18 Jun 2018 17:24:54 +0200
169b9a
Subject: [PATCH 06/17] iotests: Repairing error during snapshot deletion
169b9a
169b9a
RH-Author: Max Reitz <mreitz@redhat.com>
169b9a
Message-id: <20180618172454.27434-3-mreitz@redhat.com>
169b9a
Patchwork-id: 80787
169b9a
O-Subject: [RHEL-7.6 qemu-kvm PATCH 2/2] iotests: Repairing error during snapshot deletion
169b9a
Bugzilla: 1527122
169b9a
RH-Acked-by: John Snow <jsnow@redhat.com>
169b9a
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
169b9a
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
169b9a
169b9a
This adds a test for an I/O error during snapshot deletion, and maybe
169b9a
more importantly, for how to repair the resulting image.  If the
169b9a
snapshot has been deleted before the error occurs, the only negative
169b9a
result will be leaked clusters -- and those should be repairable with
169b9a
qemu-img check -r leaks.
169b9a
169b9a
Signed-off-by: Max Reitz <mreitz@redhat.com>
169b9a
Reviewed-by: Eric Blake <eblake@redhat.com>
169b9a
Message-id: 20180509200059.31125-3-mreitz@redhat.com
169b9a
Signed-off-by: Max Reitz <mreitz@redhat.com>
169b9a
(cherry picked from commit b41ad73a3bb972eb43cf52d28669f67ea3fe1762)
169b9a
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
169b9a
169b9a
Conflicts:
169b9a
	tests/qemu-iotests/group
169b9a
	tests/qemu-iotests/217.out
169b9a
169b9a
The error message when a snapshot failed to be deleted is less verbose
169b9a
(just based on errno instead of a nice Error object).
169b9a
169b9a
Signed-off-by: Max Reitz <mreitz@redhat.com>
169b9a
---
169b9a
 tests/qemu-iotests/217     | 90 ++++++++++++++++++++++++++++++++++++++++++++++
169b9a
 tests/qemu-iotests/217.out | 42 ++++++++++++++++++++++
169b9a
 tests/qemu-iotests/group   |  1 +
169b9a
 3 files changed, 133 insertions(+)
169b9a
 create mode 100755 tests/qemu-iotests/217
169b9a
 create mode 100644 tests/qemu-iotests/217.out
169b9a
169b9a
diff --git a/tests/qemu-iotests/217 b/tests/qemu-iotests/217
169b9a
new file mode 100755
169b9a
index 0000000..d3ab5d7
169b9a
--- /dev/null
169b9a
+++ b/tests/qemu-iotests/217
169b9a
@@ -0,0 +1,90 @@
169b9a
+#!/bin/bash
169b9a
+#
169b9a
+# I/O errors when working with internal qcow2 snapshots, and repairing
169b9a
+# the result
169b9a
+#
169b9a
+# Copyright (C) 2018 Red Hat, Inc.
169b9a
+#
169b9a
+# This program is free software; you can redistribute it and/or modify
169b9a
+# it under the terms of the GNU General Public License as published by
169b9a
+# the Free Software Foundation; either version 2 of the License, or
169b9a
+# (at your option) any later version.
169b9a
+#
169b9a
+# This program is distributed in the hope that it will be useful,
169b9a
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
169b9a
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
169b9a
+# GNU General Public License for more details.
169b9a
+#
169b9a
+# You should have received a copy of the GNU General Public License
169b9a
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
169b9a
+
169b9a
+seq=$(basename $0)
169b9a
+echo "QA output created by $seq"
169b9a
+
169b9a
+status=1	# failure is the default!
169b9a
+
169b9a
+_cleanup()
169b9a
+{
169b9a
+    _cleanup_test_img
169b9a
+    rm -f "$TEST_DIR/blkdebug.conf"
169b9a
+}
169b9a
+trap "_cleanup; exit \$status" 0 1 2 3 15
169b9a
+
169b9a
+# get standard environment, filters and checks
169b9a
+. ./common.rc
169b9a
+. ./common.filter
169b9a
+
169b9a
+# This test is specific to qcow2
169b9a
+_supported_fmt qcow2
169b9a
+_supported_proto file
169b9a
+_supported_os Linux
169b9a
+
169b9a
+# This test needs clusters with at least a refcount of 2 so that
169b9a
+# OFLAG_COPIED is not set.  refcount_bits=1 is therefore unsupported.
169b9a
+_unsupported_imgopts 'refcount_bits=1[^0-9]'
169b9a
+
169b9a
+echo
169b9a
+echo '=== Simulating an I/O error during snapshot deletion ==='
169b9a
+echo
169b9a
+
169b9a
+_make_test_img 64M
169b9a
+$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
169b9a
+
169b9a
+# Create the snapshot
169b9a
+$QEMU_IMG snapshot -c foo "$TEST_IMG"
169b9a
+
169b9a
+# Verify the snapshot is there
169b9a
+echo
169b9a
+_img_info | grep 'Snapshot list'
169b9a
+echo '(Snapshot filtered)'
169b9a
+echo
169b9a
+
169b9a
+# Try to delete the snapshot (with an error happening when freeing the
169b9a
+# then leaked clusters)
169b9a
+cat > "$TEST_DIR/blkdebug.conf" <
169b9a
+[inject-error]
169b9a
+event = "cluster_free"
169b9a
+errno = "5"
169b9a
+EOF
169b9a
+$QEMU_IMG snapshot -d foo "blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
169b9a
+
169b9a
+# Verify the snapshot is gone
169b9a
+echo
169b9a
+_img_info | grep 'Snapshot list'
169b9a
+
169b9a
+# Should only show leaks
169b9a
+echo '--- Checking test image ---'
169b9a
+_check_test_img
169b9a
+
169b9a
+echo
169b9a
+
169b9a
+# As there are only leaks, this should be able to fully repair the
169b9a
+# image
169b9a
+echo '--- Repairing test image ---'
169b9a
+_check_test_img -r leaks
169b9a
+
169b9a
+
169b9a
+# success, all done
169b9a
+echo '*** done'
169b9a
+rm -f $seq.full
169b9a
+status=0
169b9a
diff --git a/tests/qemu-iotests/217.out b/tests/qemu-iotests/217.out
169b9a
new file mode 100644
169b9a
index 0000000..4b1020b
169b9a
--- /dev/null
169b9a
+++ b/tests/qemu-iotests/217.out
169b9a
@@ -0,0 +1,42 @@
169b9a
+QA output created by 217
169b9a
+
169b9a
+=== Simulating an I/O error during snapshot deletion ===
169b9a
+
169b9a
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
169b9a
+wrote 65536/65536 bytes at offset 0
169b9a
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
169b9a
+
169b9a
+Snapshot list:
169b9a
+(Snapshot filtered)
169b9a
+
169b9a
+qcow2_free_clusters failed: Input/output error
169b9a
+qemu-img: Could not delete snapshot 'foo': -5 (Input/output error)
169b9a
+
169b9a
+--- Checking test image ---
169b9a
+Leaked cluster 4 refcount=2 reference=1
169b9a
+Leaked cluster 5 refcount=2 reference=1
169b9a
+Leaked cluster 6 refcount=1 reference=0
169b9a
+Leaked cluster 7 refcount=1 reference=0
169b9a
+
169b9a
+4 leaked clusters were found on the image.
169b9a
+This means waste of disk space, but no harm to data.
169b9a
+
169b9a
+--- Repairing test image ---
169b9a
+Leaked cluster 4 refcount=2 reference=1
169b9a
+Leaked cluster 5 refcount=2 reference=1
169b9a
+Leaked cluster 6 refcount=1 reference=0
169b9a
+Leaked cluster 7 refcount=1 reference=0
169b9a
+Repairing cluster 4 refcount=2 reference=1
169b9a
+Repairing cluster 5 refcount=2 reference=1
169b9a
+Repairing cluster 6 refcount=1 reference=0
169b9a
+Repairing cluster 7 refcount=1 reference=0
169b9a
+Repairing OFLAG_COPIED L2 cluster: l1_index=0 l1_entry=40000 refcount=1
169b9a
+Repairing OFLAG_COPIED data cluster: l2_entry=50000 refcount=1
169b9a
+The following inconsistencies were found and repaired:
169b9a
+
169b9a
+    4 leaked clusters
169b9a
+    2 corruptions
169b9a
+
169b9a
+Double checking the fixed image now...
169b9a
+No errors were found on the image.
169b9a
+*** done
169b9a
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
169b9a
index c1fc89d..8c96d65 100644
169b9a
--- a/tests/qemu-iotests/group
169b9a
+++ b/tests/qemu-iotests/group
169b9a
@@ -93,3 +93,4 @@
169b9a
 121 rw auto
169b9a
 130 rw auto quick
169b9a
 135 rw auto
169b9a
+217 rw auto quick
169b9a
-- 
169b9a
1.8.3.1
169b9a