Blame SOURCES/kvm-block-iotest-to-catch-abort-on-forced-blockjob-cance.patch

357786
From 981ab75d595c2aa8477cab9b514d3ba50e895c9f Mon Sep 17 00:00:00 2001
357786
From: Jeffrey Cody <jcody@redhat.com>
357786
Date: Tue, 28 Aug 2018 21:08:18 +0200
357786
Subject: [PATCH 05/29] block: iotest to catch abort on forced blockjob cancel
357786
357786
RH-Author: Jeffrey Cody <jcody@redhat.com>
357786
Message-id: <ec9206fa4f62ff4d1272a5184a7586f6b731dd99.1535490170.git.jcody@redhat.com>
357786
Patchwork-id: 81956
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 3/3] block: iotest to catch abort on forced blockjob cancel
357786
Bugzilla: 1605026
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
357786
Signed-off-by: Jeff Cody <jcody@redhat.com>
357786
Reviewed-by: John Snow <jsnow@redhat.com>
357786
Message-id: df317f617fbe5affcf699cb8560e7b0c2e028a64.1534868459.git.jcody@redhat.com
357786
Signed-off-by: Jeff Cody <jcody@redhat.com>
357786
(cherry picked from commit 26bf474ba92c76e61bea51726e22da6dfd185296)
357786
Signed-off-by: Jeff Cody <jcody@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/qemu-iotests/229     | 95 ++++++++++++++++++++++++++++++++++++++++++++++
357786
 tests/qemu-iotests/229.out | 23 +++++++++++
357786
 tests/qemu-iotests/group   |  1 +
357786
 3 files changed, 119 insertions(+)
357786
 create mode 100755 tests/qemu-iotests/229
357786
 create mode 100644 tests/qemu-iotests/229.out
357786
357786
diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229
357786
new file mode 100755
357786
index 0000000..ff851ec
357786
--- /dev/null
357786
+++ b/tests/qemu-iotests/229
357786
@@ -0,0 +1,95 @@
357786
+#!/bin/bash
357786
+#
357786
+# Test for force canceling a running blockjob that is paused in
357786
+# an error state.
357786
+#
357786
+# Copyright (C) 2018 Red Hat, Inc.
357786
+#
357786
+# This program is free software; you can redistribute it and/or modify
357786
+# it under the terms of the GNU General Public License as published by
357786
+# the Free Software Foundation; either version 2 of the License, or
357786
+# (at your option) any later version.
357786
+#
357786
+# This program is distributed in the hope that it will be useful,
357786
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
357786
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
357786
+# GNU General Public License for more details.
357786
+#
357786
+# You should have received a copy of the GNU General Public License
357786
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
357786
+#
357786
+
357786
+# creator
357786
+owner=jcody@redhat.com
357786
+
357786
+seq="$(basename $0)"
357786
+echo "QA output created by $seq"
357786
+
357786
+here="$PWD"
357786
+status=1	# failure is the default!
357786
+
357786
+_cleanup()
357786
+{
357786
+    _cleanup_qemu
357786
+    _cleanup_test_img
357786
+    rm -f "$TEST_IMG" "$DEST_IMG"
357786
+}
357786
+trap "_cleanup; exit \$status" 0 1 2 3 15
357786
+
357786
+# get standard environment, filters and checks
357786
+. ./common.rc
357786
+. ./common.filter
357786
+. ./common.qemu
357786
+
357786
+# Needs backing file and backing format support
357786
+_supported_fmt qcow2 qed
357786
+_supported_proto file
357786
+_supported_os Linux
357786
+
357786
+
357786
+DEST_IMG="$TEST_DIR/d.$IMGFMT"
357786
+TEST_IMG="$TEST_DIR/b.$IMGFMT"
357786
+
357786
+_make_test_img 2M
357786
+
357786
+# destination for mirror will be too small, causing error
357786
+TEST_IMG=$DEST_IMG _make_test_img 1M
357786
+
357786
+$QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
357786
+
357786
+_launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT"
357786
+
357786
+_send_qemu_cmd $QEMU_HANDLE \
357786
+    "{'execute': 'qmp_capabilities'}" \
357786
+    'return'
357786
+
357786
+echo
357786
+echo '=== Starting drive-mirror, causing error & stop  ==='
357786
+echo
357786
+
357786
+_send_qemu_cmd $QEMU_HANDLE \
357786
+    "{'execute': 'drive-mirror',
357786
+                 'arguments': {'device': 'testdisk',
357786
+                               'mode':   'absolute-paths',
357786
+                               'format': '$IMGFMT',
357786
+                               'target': '$DEST_IMG',
357786
+                               'sync':   'full',
357786
+                               'mode':   'existing',
357786
+                               'on-source-error': 'stop',
357786
+                               'on-target-error': 'stop' }}"    \
357786
+     "JOB_STATUS_CHANGE.*pause"
357786
+
357786
+echo
357786
+echo '=== Force cancel job paused in error state  ==='
357786
+echo
357786
+
357786
+success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
357786
+    "{'execute': 'block-job-cancel',
357786
+                 'arguments': { 'device': 'testdisk',
357786
+                                'force': true}}" \
357786
+     "BLOCK_JOB_CANCELLED" "Assertion"
357786
+
357786
+# success, all done
357786
+echo "*** done"
357786
+rm -f $seq.full
357786
+status=0
357786
diff --git a/tests/qemu-iotests/229.out b/tests/qemu-iotests/229.out
357786
new file mode 100644
357786
index 0000000..4c41128
357786
--- /dev/null
357786
+++ b/tests/qemu-iotests/229.out
357786
@@ -0,0 +1,23 @@
357786
+QA output created by 229
357786
+Formatting 'TEST_DIR/b.IMGFMT', fmt=IMGFMT size=2097152
357786
+Formatting 'TEST_DIR/d.IMGFMT', fmt=IMGFMT size=1048576
357786
+wrote 2097152/2097152 bytes at offset 0
357786
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+{"return": {}}
357786
+
357786
+=== Starting drive-mirror, causing error & stop  ===
357786
+
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "testdisk"}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}}
357786
+{"return": {}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_ERROR", "data": {"device": "testdisk", "operation": "write", "action": "stop"}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "paused", "id": "testdisk"}}
357786
+
357786
+=== Force cancel job paused in error state  ===
357786
+
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}}
357786
+{"return": {}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_ERROR", "data": {"device": "testdisk", "operation": "write", "action": "stop"}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "testdisk"}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "testdisk", "len": 2097152, "offset": 1048576, "speed": 0, "type": "mirror"}}
357786
+*** done
357786
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
357786
index 6dd146a..3817d28 100644
357786
--- a/tests/qemu-iotests/group
357786
+++ b/tests/qemu-iotests/group
357786
@@ -223,3 +223,4 @@
357786
 223 rw auto quick
357786
 226 auto quick
357786
 227 auto quick
357786
+229 auto quick
357786
-- 
357786
1.8.3.1
357786