]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/191
iotests: Fix 195 if IMGFMT is part of TEST_DIR
[mirror_qemu.git] / tests / qemu-iotests / 191
1 #!/bin/bash
2 #
3 # Test commit block job where top has two parents
4 #
5 # Copyright (C) 2017 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 owner=kwolf@redhat.com
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 status=1 # failure is the default!
29
30 MIG_SOCKET="${TEST_DIR}/migrate"
31
32 _cleanup()
33 {
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
39 }
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.qemu
46
47 _supported_fmt qcow2
48 _unsupported_imgopts compat=0.10
49 _supported_proto file
50 _supported_os Linux
51
52 size=64M
53
54 echo
55 echo === Preparing and starting VM ===
56 echo
57
58 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
59 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base"
60 _make_test_img -b "${TEST_IMG}.mid"
61 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"
62
63 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
64
65 qemu_comm_method="qmp"
66 qmp_pretty="y"
67
68 _launch_qemu \
69 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.base,node-name=base" \
70 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.mid,node-name=mid,backing=base" \
71 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG},node-name=top,backing=mid" \
72 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.ovl2,node-name=top2,backing=mid"
73 h=$QEMU_HANDLE
74 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
75
76 echo
77 echo === Perform commit job ===
78 echo
79
80 _send_qemu_cmd $h \
81 "{ 'execute': 'block-commit',
82 'arguments': { 'job-id': 'commit0',
83 'device': 'top',
84 'base':'$TEST_IMG.base',
85 'top': '$TEST_IMG.mid' } }" \
86 "BLOCK_JOB_COMPLETED"
87 _send_qemu_cmd $h "" "^}"
88
89 echo
90 echo === Check that both top and top2 point to base now ===
91 echo
92
93 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
94 _filter_generated_node_ids
95
96 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
97 wait=1 _cleanup_qemu
98
99 _img_info
100 TEST_IMG="$TEST_IMG.ovl2" _img_info
101
102
103 echo
104 echo === Preparing and starting VM with -drive ===
105 echo
106
107 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
108 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base"
109 _make_test_img -b "${TEST_IMG}.mid"
110 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"
111 TEST_IMG="${TEST_IMG}.ovl3" _make_test_img -b "${TEST_IMG}.ovl2"
112
113 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
114
115 qemu_comm_method="qmp"
116 qmp_pretty="y"
117
118 _launch_qemu \
119 -drive "driver=${IMGFMT},file=${TEST_IMG},node-name=top,backing.node-name=mid" \
120 -drive "driver=${IMGFMT},file=${TEST_IMG}.ovl3,node-name=top2,backing.backing=mid"
121 h=$QEMU_HANDLE
122 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
123
124 echo
125 echo === Perform commit job ===
126 echo
127
128 _send_qemu_cmd $h \
129 "{ 'execute': 'block-commit',
130 'arguments': { 'job-id': 'commit0',
131 'device': 'top',
132 'base':'$TEST_IMG.base',
133 'top': '$TEST_IMG.mid' } }" \
134 "BLOCK_JOB_COMPLETED"
135 _send_qemu_cmd $h "" "^}"
136
137 echo
138 echo === Check that both top and top2 point to base now ===
139 echo
140
141 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
142 _filter_generated_node_ids
143
144 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
145 wait=1 _cleanup_qemu
146
147 _img_info
148 TEST_IMG="$TEST_IMG.ovl2" _img_info
149
150 # success, all done
151 echo "*** done"
152 rm -f $seq.full
153 status=0