hpet: recover timer offset correctly
[qemu/ar7.git] / tests / qemu-iotests / 191
blobad785e10b1d8b935b1dadc5fd71146c3df1c1cf3
1 #!/bin/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 here=`pwd`
28 status=1 # failure is the default!
30 MIG_SOCKET="${TEST_DIR}/migrate"
32 _cleanup()
34 rm -f "${TEST_IMG}.mid"
35 rm -f "${TEST_IMG}.ovl2"
36 rm -f "${TEST_IMG}.ovl3"
37 _cleanup_test_img
38 _cleanup_qemu
40 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.qemu
47 _supported_fmt qcow2
48 _unsupported_imgopts compat=0.10
49 _supported_proto file
50 _supported_os Linux
52 size=64M
54 echo
55 echo === Preparing and starting VM ===
56 echo
58 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
59 IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \
60 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base"
61 _make_test_img -b "${TEST_IMG}.mid"
62 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"
64 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
66 qemu_comm_method="qmp"
67 qmp_pretty="y"
69 _launch_qemu \
70 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.base,node-name=base" \
71 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.mid,node-name=mid,backing=base" \
72 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG},node-name=top,backing=mid" \
73 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.ovl2,node-name=top2,backing=mid"
74 h=$QEMU_HANDLE
75 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
77 echo
78 echo === Perform commit job ===
79 echo
81 _send_qemu_cmd $h \
82 "{ 'execute': 'block-commit',
83 'arguments': { 'job-id': 'commit0',
84 'device': 'top',
85 'base':'$TEST_IMG.base',
86 'top': '$TEST_IMG.mid' } }" \
87 "BLOCK_JOB_COMPLETED"
88 _send_qemu_cmd $h "" "^}"
90 echo
91 echo === Check that both top and top2 point to base now ===
92 echo
94 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
95 _filter_generated_node_ids | _filter_actual_image_size
97 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
98 wait=1 _cleanup_qemu
100 _img_info
101 TEST_IMG="$TEST_IMG.ovl2" _img_info
104 echo
105 echo === Preparing and starting VM with -drive ===
106 echo
108 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
109 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base"
110 _make_test_img -b "${TEST_IMG}.mid"
111 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"
112 TEST_IMG="${TEST_IMG}.ovl3" _make_test_img -b "${TEST_IMG}.ovl2"
114 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
116 qemu_comm_method="qmp"
117 qmp_pretty="y"
119 _launch_qemu \
120 -drive "driver=${IMGFMT},file=${TEST_IMG},node-name=top,backing.node-name=mid" \
121 -drive "driver=${IMGFMT},file=${TEST_IMG}.ovl3,node-name=top2,backing.backing=mid"
122 h=$QEMU_HANDLE
123 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
125 echo
126 echo === Perform commit job ===
127 echo
129 _send_qemu_cmd $h \
130 "{ 'execute': 'block-commit',
131 'arguments': { 'job-id': 'commit0',
132 'device': 'top',
133 'base':'$TEST_IMG.base',
134 'top': '$TEST_IMG.mid' } }" \
135 "BLOCK_JOB_COMPLETED"
136 _send_qemu_cmd $h "" "^}"
138 echo
139 echo === Check that both top and top2 point to base now ===
140 echo
142 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
143 _filter_generated_node_ids | _filter_actual_image_size
145 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
146 wait=1 _cleanup_qemu
148 _img_info
149 TEST_IMG="$TEST_IMG.ovl2" _img_info
151 # success, all done
152 echo "*** done"
153 rm -f $seq.full
154 status=0