yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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