clock: Define and use new clock_display_freq()
[qemu/ar7.git] / tests / qemu-iotests / 229
blob273ac2472d71f84f05a46bf076622fe0fd6626e1
1 #!/usr/bin/env bash
3 # Test for force canceling a running blockjob that is paused in
4 # an error state.
6 # Copyright (C) 2018 Red Hat, Inc.
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.
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.
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/>.
22 # creator
23 owner=jcody@redhat.com
25 seq="$(basename $0)"
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_qemu
33 _cleanup_test_img
34 _rm_test_img "$TEST_IMG"
35 _rm_test_img "$DEST_IMG"
36 rm -f "$TEST_DIR/blkdebug.conf"
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 . ./common.qemu
45 # Needs backing file and backing format support
46 _supported_fmt qcow2 qed
47 _supported_proto file fuse
48 _supported_os Linux
49 # blkdebug can only inject errors on bs->file, so external data files
50 # do not work with this test
51 _unsupported_imgopts data_file
54 DEST_IMG="$TEST_IMG.dest"
55 BLKDEBUG_CONF="$TEST_DIR/blkdebug.conf"
57 _make_test_img 2M
58 TEST_IMG=$DEST_IMG _make_test_img 2M
60 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
62 _launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT"
64 _send_qemu_cmd $QEMU_HANDLE \
65 "{'execute': 'qmp_capabilities'}" \
66 'return'
68 echo
69 echo '=== Starting drive-mirror, causing error & stop ==='
70 echo
72 cat > "$BLKDEBUG_CONF" <<EOF
73 [inject-error]
74 event = "write_aio"
75 errno = "5"
76 once = "on"
77 EOF
79 _send_qemu_cmd $QEMU_HANDLE \
80 "{'execute': 'drive-mirror',
81 'arguments': {'device': 'testdisk',
82 'format': '$IMGFMT',
83 'target': 'blkdebug:$BLKDEBUG_CONF:$DEST_IMG',
84 'sync': 'full',
85 'mode': 'existing',
86 'on-source-error': 'stop',
87 'on-target-error': 'stop' }}" \
88 "JOB_STATUS_CHANGE.*pause"
90 echo
91 echo '=== Force cancel job paused in error state ==='
92 echo
94 # Filter out BLOCK_JOB_ERROR events because they may or may not occur.
95 # Cancelling the job means resuming it for a bit before it is actually
96 # aborted, and in that time it may or may not re-encounter the error.
97 success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
98 "{'execute': 'block-job-cancel',
99 'arguments': { 'device': 'testdisk',
100 'force': true}}" \
101 "BLOCK_JOB_CANCELLED" "Assertion" \
102 | grep -v '"BLOCK_JOB_ERROR"' \
103 | _filter_block_job_offset
105 # success, all done
106 echo "*** done"
107 rm -f $seq.full
108 status=0