]> Git Repo - qemu.git/blob - tests/qemu-iotests/229
block: Generically refresh runtime options
[qemu.git] / tests / qemu-iotests / 229
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
23 [email protected]
24
25 seq="$(basename $0)"
26 echo "QA output created by $seq"
27
28 status=1        # failure is the default!
29
30 _cleanup()
31 {
32     _cleanup_qemu
33     _cleanup_test_img
34     rm -f "$TEST_IMG" "$DEST_IMG"
35 }
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41 . ./common.qemu
42
43 # Needs backing file and backing format support
44 _supported_fmt qcow2 qed
45 _supported_proto file
46 _supported_os Linux
47
48
49 DEST_IMG="$TEST_DIR/d.$IMGFMT"
50 TEST_IMG="$TEST_DIR/b.$IMGFMT"
51
52 _make_test_img 2M
53
54 # destination for mirror will be too small, causing error
55 TEST_IMG=$DEST_IMG _make_test_img 1M
56
57 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io
58
59 _launch_qemu -drive id=testdisk,file="$TEST_IMG",format="$IMGFMT"
60
61 _send_qemu_cmd $QEMU_HANDLE \
62     "{'execute': 'qmp_capabilities'}" \
63     'return'
64
65 echo
66 echo '=== Starting drive-mirror, causing error & stop  ==='
67 echo
68
69 _send_qemu_cmd $QEMU_HANDLE \
70     "{'execute': 'drive-mirror',
71                  'arguments': {'device': 'testdisk',
72                                'format': '$IMGFMT',
73                                'target': '$DEST_IMG',
74                                'sync':   'full',
75                                'mode':   'existing',
76                                'on-source-error': 'stop',
77                                'on-target-error': 'stop' }}"    \
78      "JOB_STATUS_CHANGE.*pause"
79
80 echo
81 echo '=== Force cancel job paused in error state  ==='
82 echo
83
84 # Filter out BLOCK_JOB_ERROR events because they may or may not occur.
85 # Cancelling the job means resuming it for a bit before it is actually
86 # aborted, and in that time it may or may not re-encounter the error.
87 success_or_failure="y" _send_qemu_cmd $QEMU_HANDLE \
88     "{'execute': 'block-job-cancel',
89                  'arguments': { 'device': 'testdisk',
90                                 'force': true}}" \
91      "BLOCK_JOB_CANCELLED" "Assertion" \
92     | grep -v '"BLOCK_JOB_ERROR"'
93
94 # success, all done
95 echo "*** done"
96 rm -f $seq.full
97 status=0
This page took 0.027515 seconds and 4 git commands to generate.