docs: rstfy vfio-ap documentation
[qemu/ar7.git] / tests / qemu-iotests / 229
blob866168b236b482c8f249a36f604267d4b6d7509a
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"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42 . ./common.qemu
44 # Needs backing file and backing format support
45 _supported_fmt qcow2 qed
46 _supported_proto file
47 _supported_os Linux
50 DEST_IMG="$TEST_DIR/d.$IMGFMT"
51 TEST_IMG="$TEST_DIR/b.$IMGFMT"
53 _make_test_img 2M
55 # destination for mirror will be too small, causing error
56 TEST_IMG=$DEST_IMG _make_test_img 1M
58 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
60 _launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT"
62 _send_qemu_cmd $QEMU_HANDLE \
63 "{'execute': 'qmp_capabilities'}" \
64 'return'
66 echo
67 echo '=== Starting drive-mirror, causing error & stop ==='
68 echo
70 _send_qemu_cmd $QEMU_HANDLE \
71 "{'execute': 'drive-mirror',
72 'arguments': {'device': 'testdisk',
73 'format': '$IMGFMT',
74 'target': '$DEST_IMG',
75 'sync': 'full',
76 'mode': 'existing',
77 'on-source-error': 'stop',
78 'on-target-error': 'stop' }}" \
79 "JOB_STATUS_CHANGE.*pause"
81 echo
82 echo '=== Force cancel job paused in error state ==='
83 echo
85 # Filter out BLOCK_JOB_ERROR events because they may or may not occur.
86 # Cancelling the job means resuming it for a bit before it is actually
87 # aborted, and in that time it may or may not re-encounter the error.
88 success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
89 "{'execute': 'block-job-cancel',
90 'arguments': { 'device': 'testdisk',
91 'force': true}}" \
92 "BLOCK_JOB_CANCELLED" "Assertion" \
93 | grep -v '"BLOCK_JOB_ERROR"'
95 # success, all done
96 echo "*** done"
97 rm -f $seq.full
98 status=0