qapi/error: Check format string argument in error_*prepend()
[qemu/armbru.git] / tests / qemu-iotests / 191
blobd17462e1e42baac0a59603918ec87506b58eda03
1 #!/usr/bin/env bash
3 # Test commit block job where top has two parents
5 # Copyright (C) 2017 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 _cleanup()
31 _rm_test_img "${TEST_IMG}.mid"
32 _rm_test_img "${TEST_IMG}.ovl2"
33 _rm_test_img "${TEST_IMG}.ovl3"
34 _cleanup_test_img
35 _cleanup_qemu
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 _supported_fmt qcow2
45 _supported_proto file
46 # An external data file would change the query-named-block-nodes output
47 _unsupported_imgopts data_file
49 size=64M
51 echo
52 echo === Preparing and starting VM ===
53 echo
55 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
56 TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base"
57 _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
58 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
60 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
62 qemu_comm_method="qmp"
63 qmp_pretty="y"
65 _launch_qemu \
66 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.base,node-name=base" \
67 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.mid,node-name=mid,backing=base" \
68 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG},node-name=top,backing=mid" \
69 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.ovl2,node-name=top2,backing=mid"
70 h=$QEMU_HANDLE
71 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
73 echo
74 echo === Perform commit job ===
75 echo
77 _send_qemu_cmd $h \
78 "{ 'execute': 'block-commit',
79 'arguments': { 'job-id': 'commit0',
80 'device': 'top',
81 'base':'$TEST_IMG.base',
82 'top': '$TEST_IMG.mid' } }" \
83 '"status": "null"'
84 _send_qemu_cmd $h "" "^}"
86 echo
87 echo === Check that both top and top2 point to base now ===
88 echo
90 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
91 _filter_generated_node_ids | _filter_actual_image_size | _filter_img_info
93 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
94 wait=1 _cleanup_qemu
96 _img_info
97 TEST_IMG="$TEST_IMG.ovl2" _img_info
100 echo
101 echo === Preparing and starting VM with -drive ===
102 echo
104 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
105 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" -F $IMGFMT
106 _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
107 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
108 TEST_IMG="${TEST_IMG}.ovl3" _make_test_img -b "${TEST_IMG}.ovl2" -F $IMGFMT
110 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
112 qemu_comm_method="qmp"
113 qmp_pretty="y"
115 _launch_qemu \
116 -drive "driver=${IMGFMT},file=${TEST_IMG},node-name=top,backing.node-name=mid" \
117 -drive "driver=${IMGFMT},file=${TEST_IMG}.ovl3,node-name=top2,backing.backing=mid"
118 h=$QEMU_HANDLE
119 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
121 echo
122 echo === Perform commit job ===
123 echo
125 _send_qemu_cmd $h \
126 "{ 'execute': 'block-commit',
127 'arguments': { 'job-id': 'commit0',
128 'device': 'top',
129 'base':'$TEST_IMG.base',
130 'top': '$TEST_IMG.mid' } }" \
131 '"status": "null"'
132 _send_qemu_cmd $h "" "^}"
134 echo
135 echo === Check that both top and top2 point to base now ===
136 echo
138 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
139 _filter_generated_node_ids | _filter_actual_image_size | _filter_img_info
141 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
142 wait=1 _cleanup_qemu
144 _img_info
145 TEST_IMG="$TEST_IMG.ovl2" _img_info
147 # success, all done
148 echo "*** done"
149 rm -f $seq.full
150 status=0