1#!/bin/bash 2# 3# Test for force canceling a running blockjob that is paused in 4# an error state. 5# 6# Copyright (C) 2018 Red Hat, Inc. 7# 8# This program is free software; you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation; either version 2 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see <http://www.gnu.org/licenses/>. 20# 21 22# creator 23owner=jcody@redhat.com 24 25seq="$(basename $0)" 26echo "QA output created by $seq" 27 28here="$PWD" 29status=1 # failure is the default! 30 31_cleanup() 32{ 33 _cleanup_qemu 34 _cleanup_test_img 35 rm -f "$TEST_IMG" "$DEST_IMG" 36} 37trap "_cleanup; exit \$status" 0 1 2 3 15 38 39# get standard environment, filters and checks 40. ./common.rc 41. ./common.filter 42. ./common.qemu 43 44# Needs backing file and backing format support 45_supported_fmt qcow2 qed 46_supported_proto file 47_supported_os Linux 48 49 50DEST_IMG="$TEST_DIR/d.$IMGFMT" 51TEST_IMG="$TEST_DIR/b.$IMGFMT" 52 53_make_test_img 2M 54 55# destination for mirror will be too small, causing error 56TEST_IMG=$DEST_IMG _make_test_img 1M 57 58$QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io 59 60_launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT" 61 62_send_qemu_cmd $QEMU_HANDLE \ 63 "{'execute': 'qmp_capabilities'}" \ 64 'return' 65 66echo 67echo '=== Starting drive-mirror, causing error & stop ===' 68echo 69 70_send_qemu_cmd $QEMU_HANDLE \ 71 "{'execute': 'drive-mirror', 72 'arguments': {'device': 'testdisk', 73 'mode': 'absolute-paths', 74 'format': '$IMGFMT', 75 'target': '$DEST_IMG', 76 'sync': 'full', 77 'mode': 'existing', 78 'on-source-error': 'stop', 79 'on-target-error': 'stop' }}" \ 80 "JOB_STATUS_CHANGE.*pause" 81 82echo 83echo '=== Force cancel job paused in error state ===' 84echo 85 86success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \ 87 "{'execute': 'block-job-cancel', 88 'arguments': { 'device': 'testdisk', 89 'force': true}}" \ 90 "BLOCK_JOB_CANCELLED" "Assertion" 91 92# success, all done 93echo "*** done" 94rm -f $seq.full 95status=0 96