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

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