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