]> Git Repo - qemu.git/blame - tests/qemu-iotests/185
block: Use JSON null instead of "" to disable backing file
[qemu.git] / tests / qemu-iotests / 185
CommitLineData
24575bfa
KW
1#!/bin/bash
2#
3# Test exiting qemu while jobs are still running
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[email protected]
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
28status=1 # failure is the default!
29
30MIG_SOCKET="${TEST_DIR}/migrate"
31
32_cleanup()
33{
34 rm -f "${TEST_IMG}.mid"
35 rm -f "${TEST_IMG}.copy"
36 _cleanup_test_img
37 _cleanup_qemu
38}
39trap "_cleanup; exit \$status" 0 1 2 3 15
40
41# get standard environment, filters and checks
42. ./common.rc
43. ./common.filter
44. ./common.qemu
45
46_supported_fmt qcow2
47_supported_proto file
48_supported_os Linux
49
50size=64M
51TEST_IMG="${TEST_IMG}.base" _make_test_img $size
52
53echo
54echo === Starting VM ===
55echo
56
57qemu_comm_method="qmp"
58
59_launch_qemu \
60 -drive file="${TEST_IMG}.base",cache=$CACHEMODE,driver=$IMGFMT,id=disk
61h=$QEMU_HANDLE
62_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return'
63
64echo
65echo === Creating backing chain ===
66echo
67
68_send_qemu_cmd $h \
69 "{ 'execute': 'blockdev-snapshot-sync',
70 'arguments': { 'device': 'disk',
71 'snapshot-file': '$TEST_IMG.mid',
72 'format': '$IMGFMT',
73 'mode': 'absolute-paths' } }" \
74 "return"
75
76_send_qemu_cmd $h \
77 "{ 'execute': 'human-monitor-command',
78 'arguments': { 'command-line':
79 'qemu-io disk \"write 0 4M\"' } }" \
80 "return"
81
82_send_qemu_cmd $h \
83 "{ 'execute': 'blockdev-snapshot-sync',
84 'arguments': { 'device': 'disk',
85 'snapshot-file': '$TEST_IMG',
86 'format': '$IMGFMT',
87 'mode': 'absolute-paths' } }" \
88 "return"
89
90echo
91echo === Start commit job and exit qemu ===
92echo
93
94# Note that the reference output intentionally includes the 'offset' field in
95# BLOCK_JOB_CANCELLED events for all of the following block jobs. They are
96# predictable and any change in the offsets would hint at a bug in the job
97# throttling code.
98#
99# In order to achieve these predictable offsets, all of the following tests
100# use speed=65536. Each job will perform exactly one iteration before it has
101# to sleep at least for a second, which is plenty of time for the 'quit' QMP
102# command to be received (after receiving the command, the rest runs
103# synchronously, so jobs can arbitrarily continue or complete).
104#
105# The buffer size for commit and streaming is 512k (waiting for 8 seconds after
106# the first request), for active commit and mirror it's large enough to cover
107# the full 4M, and for backup it's the qcow2 cluster size, which we know is
108# 64k. As all of these are at least as large as the speed, we are sure that the
109# offset doesn't advance after the first iteration before qemu exits.
110
111_send_qemu_cmd $h \
112 "{ 'execute': 'block-commit',
113 'arguments': { 'device': 'disk',
114 'base':'$TEST_IMG.base',
115 'top': '$TEST_IMG.mid',
116 'speed': 65536 } }" \
117 "return"
118
119_send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
120wait=1 _cleanup_qemu
121
122echo
123echo === Start active commit job and exit qemu ===
124echo
125
126_launch_qemu \
127 -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
128h=$QEMU_HANDLE
129_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return'
130
131_send_qemu_cmd $h \
132 "{ 'execute': 'block-commit',
133 'arguments': { 'device': 'disk',
134 'base':'$TEST_IMG.base',
135 'speed': 65536 } }" \
136 "return"
137
138_send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
139wait=1 _cleanup_qemu
140
141echo
142echo === Start mirror job and exit qemu ===
143echo
144
145_launch_qemu \
146 -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
147h=$QEMU_HANDLE
148_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return'
149
150_send_qemu_cmd $h \
151 "{ 'execute': 'drive-mirror',
152 'arguments': { 'device': 'disk',
153 'target': '$TEST_IMG.copy',
154 'format': '$IMGFMT',
155 'sync': 'full',
156 'speed': 65536 } }" \
157 "return"
158
159_send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
160wait=1 _cleanup_qemu
161
162echo
163echo === Start backup job and exit qemu ===
164echo
165
166_launch_qemu \
167 -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
168h=$QEMU_HANDLE
169_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return'
170
171_send_qemu_cmd $h \
172 "{ 'execute': 'drive-backup',
173 'arguments': { 'device': 'disk',
174 'target': '$TEST_IMG.copy',
175 'format': '$IMGFMT',
176 'sync': 'full',
177 'speed': 65536 } }" \
178 "return"
179
180_send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
181wait=1 _cleanup_qemu
182
183echo
184echo === Start streaming job and exit qemu ===
185echo
186
187_launch_qemu \
188 -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
189h=$QEMU_HANDLE
190_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return'
191
192_send_qemu_cmd $h \
193 "{ 'execute': 'block-stream',
194 'arguments': { 'device': 'disk',
195 'speed': 65536 } }" \
196 "return"
197
198_send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
199wait=1 _cleanup_qemu
200
201_check_test_img
202
203# success, all done
204echo "*** done"
205rm -f $seq.full
206status=0
This page took 0.055382 seconds and 4 git commands to generate.