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

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