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

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