]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/061
iotests: Disable data_file where it cannot be used
[mirror_qemu.git] / tests / qemu-iotests / 061
CommitLineData
11a82d14 1#!/usr/bin/env bash
a8110c3d
HR
2#
3# Test case for image option amendment in qcow2.
4#
5# Copyright (C) 2013 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
22owner=mreitz@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
a8110c3d
HR
27status=1 # failure is the default!
28
29_cleanup()
30{
ac40260d 31 _cleanup_test_img
f91ecbd7 32 _rm_test_img "$TEST_IMG.data"
a8110c3d
HR
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39
e696f335 40# This tests qcow2-specific low-level functionality
a8110c3d 41_supported_fmt qcow2
1f7bf7d0 42_supported_proto file
a8110c3d 43_supported_os Linux
407fb56a 44# Conversion between different compat versions can only really work
3be2024a
HR
45# with refcount_bits=16;
46# we have explicit tests for data_file here, but the whole test does
47# not work with it
48_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
a8110c3d
HR
49
50echo
51echo "=== Testing version downgrade with zero expansion ==="
52echo
407fb56a 53_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
a8110c3d 54$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
ea81ca9d 55$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d 56$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
ea81ca9d 57$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d
HR
58$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
59_check_test_img
60
2ecec911
AG
61echo
62echo "=== Testing version downgrade with zero expansion and 4K cache entries ==="
63echo
407fb56a 64_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
2ecec911
AG
65$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
66$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io
67$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
68$PYTHON qcow2.py "$TEST_IMG" dump-header
69$QEMU_IMG amend -o "compat=0.10" --image-opts \
70 driver=qcow2,file.filename=$TEST_IMG,l2-cache-entry-size=4096
71$PYTHON qcow2.py "$TEST_IMG" dump-header
72$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
73$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io
74$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
75_check_test_img
76
a8110c3d
HR
77echo
78echo "=== Testing dirty version downgrade ==="
79echo
407fb56a 80_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
8af224d6 81_NO_VALGRIND \
efd0fbbc
AG
82$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
83 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
ea81ca9d 84$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d 85$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
ea81ca9d 86$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d
HR
87$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
88_check_test_img
89
90echo
91echo "=== Testing version downgrade with unknown compat/autoclear flags ==="
92echo
407fb56a 93_make_test_img -o "compat=1.1" 64M
ea81ca9d
HR
94$PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42
95$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42
96$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d 97$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
ea81ca9d 98$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d
HR
99_check_test_img
100
101echo
102echo "=== Testing version upgrade and resize ==="
103echo
407fb56a 104_make_test_img -o "compat=0.10" 64M
a8110c3d 105$QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
ea81ca9d 106$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d 107$QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG"
ea81ca9d 108$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d
HR
109$QEMU_IO -c "read -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
110_check_test_img
111
112echo
113echo "=== Testing dirty lazy_refcounts=off ==="
114echo
407fb56a 115_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
8af224d6 116_NO_VALGRIND \
efd0fbbc
AG
117$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
118 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
ea81ca9d 119$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d 120$QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG"
ea81ca9d 121$PYTHON qcow2.py "$TEST_IMG" dump-header
a8110c3d
HR
122$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
123_check_test_img
124
125echo
126echo "=== Testing backing file ==="
127echo
407fb56a
HR
128_make_test_img -o "compat=1.1" 64M
129TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
a8110c3d
HR
130$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
131$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
132$QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG"
133$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
134_check_test_img
135
136echo
137echo "=== Testing invalid configurations ==="
138echo
407fb56a 139_make_test_img -o "compat=0.10" 64M
a8110c3d
HR
140$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
141$QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid
142$QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG"
143$QEMU_IMG amend -o "compat=0.42" "$TEST_IMG"
144$QEMU_IMG amend -o "foo=bar" "$TEST_IMG"
145$QEMU_IMG amend -o "cluster_size=1k" "$TEST_IMG"
146$QEMU_IMG amend -o "encryption=on" "$TEST_IMG"
147$QEMU_IMG amend -o "preallocation=on" "$TEST_IMG"
148
149echo
150echo "=== Testing correct handling of unset value ==="
151echo
407fb56a 152_make_test_img -o "compat=1.1,cluster_size=1k" 64M
a8110c3d
HR
153echo "Should work:"
154$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
155echo "Should not work:" # Just to know which of these tests actually fails
156$QEMU_IMG amend -o "cluster_size=64k" "$TEST_IMG"
157
158echo
159echo "=== Testing zero expansion on inactive clusters ==="
160echo
407fb56a 161_make_test_img -o "compat=1.1" 64M
a8110c3d
HR
162$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
163$QEMU_IMG snapshot -c foo "$TEST_IMG"
164$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
165$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
166_check_test_img
167$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
168$QEMU_IMG snapshot -a foo "$TEST_IMG"
169_check_test_img
170$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
171
d982919d
HR
172echo
173echo "=== Testing zero expansion on shared L2 table ==="
174echo
407fb56a 175_make_test_img -o "compat=1.1" 64M
d982919d
HR
176$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
177$QEMU_IMG snapshot -c foo "$TEST_IMG"
178$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
179_check_test_img
180$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
181$QEMU_IMG snapshot -a foo "$TEST_IMG"
182_check_test_img
183$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
184
a8110c3d
HR
185echo
186echo "=== Testing zero expansion on backed image ==="
187echo
407fb56a 188TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
a8110c3d 189$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
407fb56a 190_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M
a8110c3d
HR
191$QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
192$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
193_check_test_img
194$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
195
196echo
197echo "=== Testing zero expansion on backed inactive clusters ==="
198echo
407fb56a 199TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
a8110c3d 200$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
407fb56a 201_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M
a8110c3d
HR
202$QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
203$QEMU_IMG snapshot -c foo "$TEST_IMG"
204$QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
205$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
206_check_test_img
207$QEMU_IO -c "read -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
208$QEMU_IMG snapshot -a foo "$TEST_IMG"
209_check_test_img
210$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
211
d982919d
HR
212echo
213echo "=== Testing zero expansion on backed image with shared L2 table ==="
214echo
407fb56a 215TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
d982919d 216$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
407fb56a 217_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M
d982919d
HR
218$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
219$QEMU_IMG snapshot -c foo "$TEST_IMG"
220$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
221_check_test_img
222$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
223$QEMU_IMG snapshot -a foo "$TEST_IMG"
224_check_test_img
225$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
226
fd9e03e6
HR
227echo
228echo "=== Testing preallocated zero expansion on full image ==="
229echo
407fb56a 230TEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M
fd9e03e6
HR
231$QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io
232$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
233_check_test_img
234$QEMU_IO -c "read -P 0 0 64M" "$TEST_IMG" | _filter_qemu_io
235
78fa6582
HR
236echo
237echo "=== Testing progress report without snapshot ==="
238echo
407fb56a
HR
239TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
240_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G
78fa6582
HR
241$QEMU_IO -c "write -z 0 64k" \
242 -c "write -z 1G 64k" \
243 -c "write -z 2G 64k" \
244 -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
245$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
246_check_test_img
247
248echo
249echo "=== Testing progress report with snapshot ==="
250echo
407fb56a
HR
251TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
252_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G
78fa6582
HR
253$QEMU_IO -c "write -z 0 64k" \
254 -c "write -z 1G 64k" \
255 -c "write -z 2G 64k" \
256 -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
257$QEMU_IMG snapshot -c foo "$TEST_IMG"
258$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
259_check_test_img
260
ac40260d
KW
261echo
262echo "=== Testing version downgrade with external data file ==="
263echo
407fb56a 264_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
ac40260d
KW
265$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
266_img_info --format-specific
267_check_test_img
268
269echo
270echo "=== Try changing the external data file ==="
271echo
407fb56a 272_make_test_img -o "compat=1.1" 64M
ac40260d
KW
273$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
274
275echo
407fb56a 276_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
ac40260d
KW
277$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
278_img_info --format-specific
279TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
280
281echo
282$QEMU_IMG amend -o "data_file=" --image-opts "data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG"
283_img_info --format-specific
284TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
285
286echo
287echo "=== Clearing and setting data-file-raw ==="
288echo
407fb56a 289_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M
ac40260d
KW
290$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
291_img_info --format-specific
292_check_test_img
293
294$QEMU_IMG amend -o "data_file_raw=off" "$TEST_IMG"
295_img_info --format-specific
296_check_test_img
297
298$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
299_img_info --format-specific
300_check_test_img
301
302
a8110c3d
HR
303# success, all done
304echo "*** done"
305rm -f $seq.full
306status=0