Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / qemu-iotests / 229
blobaaa6996ce3ab8ccdbc62f7f79eedc8e92aaedfa9
1 #!/usr/bin/env bash
2 # group: auto quick
4 # Test for force canceling a running blockjob that is paused in
5 # an error state.
7 # Copyright (C) 2018 Red Hat, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # creator
24 owner=codyprime@gmail.com
26 seq="$(basename $0)"
27 echo "QA output created by $seq"
29 status=1 # failure is the default!
31 _cleanup()
33 _cleanup_qemu
34 _cleanup_test_img
35 _rm_test_img "$TEST_IMG"
36 _rm_test_img "$DEST_IMG"
37 rm -f "$TEST_DIR/blkdebug.conf"
39 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./common.filter
44 . ./common.qemu
46 # Needs backing file and backing format support
47 _supported_fmt qcow2 qed
48 _supported_proto file fuse
49 _supported_os Linux
50 # blkdebug can only inject errors on bs->file, so external data files
51 # do not work with this test
52 _unsupported_imgopts data_file
55 DEST_IMG="$TEST_IMG.dest"
56 BLKDEBUG_CONF="$TEST_DIR/blkdebug.conf"
58 _make_test_img 2M
59 TEST_IMG=$DEST_IMG _make_test_img 2M
61 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
63 _launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT"
65 _send_qemu_cmd $QEMU_HANDLE \
66 "{'execute': 'qmp_capabilities'}" \
67 'return'
69 echo
70 echo '=== Starting drive-mirror, causing error & stop ==='
71 echo
73 cat > "$BLKDEBUG_CONF" <<EOF
74 [inject-error]
75 event = "write_aio"
76 errno = "5"
77 once = "on"
78 EOF
80 _send_qemu_cmd $QEMU_HANDLE \
81 "{'execute': 'drive-mirror',
82 'arguments': {'device': 'testdisk',
83 'format': '$IMGFMT',
84 'target': 'blkdebug:$BLKDEBUG_CONF:$DEST_IMG',
85 'sync': 'full',
86 'mode': 'existing',
87 'on-source-error': 'stop',
88 'on-target-error': 'stop' }}" \
89 "JOB_STATUS_CHANGE.*pause"
91 echo
92 echo '=== Force cancel job paused in error state ==='
93 echo
95 # Filter out BLOCK_JOB_ERROR events because they may or may not occur.
96 # Cancelling the job means resuming it for a bit before it is actually
97 # aborted, and in that time it may or may not re-encounter the error.
98 success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
99 "{'execute': 'block-job-cancel',
100 'arguments': { 'device': 'testdisk',
101 'force': true}}" \
102 "BLOCK_JOB_CANCELLED" "Assertion" \
103 | grep -v '"BLOCK_JOB_ERROR"' \
104 | _filter_block_job_offset
106 # success, all done
107 echo "*** done"
108 rm -f $seq.full
109 status=0