xref: /openbmc/qemu/tests/qemu-iotests/061 (revision bd385a52)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto
3a8110c3dSMax Reitz#
4a8110c3dSMax Reitz# Test case for image option amendment in qcow2.
5a8110c3dSMax Reitz#
6a8110c3dSMax Reitz# Copyright (C) 2013 Red Hat, Inc.
7a8110c3dSMax Reitz#
8a8110c3dSMax Reitz# This program is free software; you can redistribute it and/or modify
9a8110c3dSMax Reitz# it under the terms of the GNU General Public License as published by
10a8110c3dSMax Reitz# the Free Software Foundation; either version 2 of the License, or
11a8110c3dSMax Reitz# (at your option) any later version.
12a8110c3dSMax Reitz#
13a8110c3dSMax Reitz# This program is distributed in the hope that it will be useful,
14a8110c3dSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
15a8110c3dSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16a8110c3dSMax Reitz# GNU General Public License for more details.
17a8110c3dSMax Reitz#
18a8110c3dSMax Reitz# You should have received a copy of the GNU General Public License
19a8110c3dSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20a8110c3dSMax Reitz#
21a8110c3dSMax Reitz
22a8110c3dSMax Reitz# creator
2342a5009dSJohn Snowowner=hreitz@redhat.com
24a8110c3dSMax Reitz
25a8110c3dSMax Reitzseq=`basename $0`
26a8110c3dSMax Reitzecho "QA output created by $seq"
27a8110c3dSMax Reitz
28a8110c3dSMax Reitzstatus=1	# failure is the default!
29a8110c3dSMax Reitz
30a8110c3dSMax Reitz_cleanup()
31a8110c3dSMax Reitz{
32a8110c3dSMax Reitz    _cleanup_test_img
33f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.data"
34a8110c3dSMax Reitz}
35a8110c3dSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36a8110c3dSMax Reitz
37a8110c3dSMax Reitz# get standard environment, filters and checks
38a8110c3dSMax Reitz. ./common.rc
39a8110c3dSMax Reitz. ./common.filter
40a8110c3dSMax Reitz
41e696f335SMax Reitz# This tests qcow2-specific low-level functionality
42a8110c3dSMax Reitz_supported_fmt qcow2
431f7bf7d0SPeter Lieven_supported_proto file
44a8110c3dSMax Reitz_supported_os Linux
45407fb56aSMax Reitz# Conversion between different compat versions can only really work
463be2024aSMax Reitz# with refcount_bits=16;
473be2024aSMax Reitz# we have explicit tests for data_file here, but the whole test does
48e7be13adSEric Blake# not work with it;
49e7be13adSEric Blake# we have explicit tests for various cluster sizes, the remaining tests
50e7be13adSEric Blake# require the default 64k cluster
51e287a351SVladimir Sementsov-Ogievskiy# we don't have explicit tests for zstd qcow2 compression type, as zstd may be
5296420a30SMichael Tokarev# not compiled in. And we can't create compat images with compression type
53e287a351SVladimir Sementsov-Ogievskiy# extension
54e287a351SVladimir Sementsov-Ogievskiy_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file \
55e287a351SVladimir Sementsov-Ogievskiy    cluster_size compression_type
56a8110c3dSMax Reitz
57a8110c3dSMax Reitzecho
58a8110c3dSMax Reitzecho "=== Testing version downgrade with zero expansion ==="
59a8110c3dSMax Reitzecho
60407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
61a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
62984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
63a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
64984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
65a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
66a8110c3dSMax Reitz_check_test_img
67a8110c3dSMax Reitz
68a8110c3dSMax Reitzecho
692ecec911SAlberto Garciaecho "=== Testing version downgrade with zero expansion and 4K cache entries ==="
702ecec911SAlberto Garciaecho
71407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
722ecec911SAlberto Garcia$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
732ecec911SAlberto Garcia$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io
742ecec911SAlberto Garcia$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
75984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
762ecec911SAlberto Garcia$QEMU_IMG amend -o "compat=0.10" --image-opts \
772ecec911SAlberto Garcia          driver=qcow2,file.filename=$TEST_IMG,l2-cache-entry-size=4096
78984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
792ecec911SAlberto Garcia$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
802ecec911SAlberto Garcia$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io
812ecec911SAlberto Garcia$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
822ecec911SAlberto Garcia_check_test_img
832ecec911SAlberto Garcia
842ecec911SAlberto Garciaecho
85a8110c3dSMax Reitzecho "=== Testing dirty version downgrade ==="
86a8110c3dSMax Reitzecho
87407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
888af224d6SAndrey Shinkevich_NO_VALGRIND \
89efd0fbbcSAlberto Garcia$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
90efd0fbbcSAlberto Garcia         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
91984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
92a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
93984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
94a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
95a8110c3dSMax Reitz_check_test_img
96a8110c3dSMax Reitz
97a8110c3dSMax Reitzecho
98a8110c3dSMax Reitzecho "=== Testing version downgrade with unknown compat/autoclear flags ==="
99a8110c3dSMax Reitzecho
100407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
101ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42
102ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42
103984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
104a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
105984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
106a8110c3dSMax Reitz_check_test_img
107a8110c3dSMax Reitz
108a8110c3dSMax Reitzecho
109a8110c3dSMax Reitzecho "=== Testing version upgrade and resize ==="
110a8110c3dSMax Reitzecho
111407fb56aSMax Reitz_make_test_img -o "compat=0.10" 64M
112a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
113984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
114a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG"
115984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
116a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
117a8110c3dSMax Reitz_check_test_img
118a8110c3dSMax Reitz
119a8110c3dSMax Reitzecho
1207fa140abSEric Blakeecho "=== Testing resize with snapshots ==="
1217fa140abSEric Blakeecho
1227fa140abSEric Blake_make_test_img -o "compat=0.10" 32M
1237fa140abSEric Blake$QEMU_IO -c "write -P 0x2a 24M 64k" "$TEST_IMG" | _filter_qemu_io
1247fa140abSEric Blake$QEMU_IMG snapshot -c foo "$TEST_IMG"
1257fa140abSEric Blake$QEMU_IMG resize "$TEST_IMG" 64M &&
1267fa140abSEric Blake    echo "unexpected pass"
127984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1287fa140abSEric Blake
1297fa140abSEric Blake$QEMU_IMG amend -o "compat=1.1,size=128M" "$TEST_IMG" ||
1307fa140abSEric Blake    echo "unexpected fail"
131984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1327fa140abSEric Blake
1337fa140abSEric Blake$QEMU_IMG snapshot -c bar "$TEST_IMG"
1347fa140abSEric Blake$QEMU_IMG resize --shrink "$TEST_IMG" 64M ||
1357fa140abSEric Blake    echo "unexpected fail"
136984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1377fa140abSEric Blake
1387fa140abSEric Blake$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" &&
1397fa140abSEric Blake    echo "unexpected pass"
140984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1417fa140abSEric Blake
1427fa140abSEric Blake$QEMU_IMG snapshot -a bar "$TEST_IMG" ||
1437fa140abSEric Blake    echo "unexpected fail"
144984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1457fa140abSEric Blake
1467fa140abSEric Blake$QEMU_IMG snapshot -d bar "$TEST_IMG"
1477fa140abSEric Blake$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" ||
1487fa140abSEric Blake    echo "unexpected fail"
149984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
1507fa140abSEric Blake
1517fa140abSEric Blake_check_test_img
1527fa140abSEric Blake
1537fa140abSEric Blake
1547fa140abSEric Blakeecho
155a8110c3dSMax Reitzecho "=== Testing dirty lazy_refcounts=off ==="
156a8110c3dSMax Reitzecho
157407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
1588af224d6SAndrey Shinkevich_NO_VALGRIND \
159efd0fbbcSAlberto Garcia$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
160efd0fbbcSAlberto Garcia         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
161984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
162a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG"
163984d7a52SVladimir Sementsov-Ogievskiy_qcow2_dump_header
164a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
165a8110c3dSMax Reitz_check_test_img
166a8110c3dSMax Reitz
167a8110c3dSMax Reitzecho
168a8110c3dSMax Reitzecho "=== Testing backing file ==="
169a8110c3dSMax Reitzecho
170407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
171407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
172a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
173a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
1745a385bf5SEric Blake$QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" \
1755a385bf5SEric Blake	  "$TEST_IMG" && echo "unexpected pass"
1765a385bf5SEric Blake$QEMU_IMG rebase -u -b "$TEST_IMG.base" -F qcow2 "$TEST_IMG"
177a8110c3dSMax Reitz$QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG"
178a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
179a8110c3dSMax Reitz_check_test_img
180a8110c3dSMax Reitz
181a8110c3dSMax Reitzecho
182a8110c3dSMax Reitzecho "=== Testing invalid configurations ==="
183a8110c3dSMax Reitzecho
184407fb56aSMax Reitz_make_test_img -o "compat=0.10" 64M
185a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
186a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid
187a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG"
188a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.42" "$TEST_IMG"
189a8110c3dSMax Reitz$QEMU_IMG amend -o "foo=bar" "$TEST_IMG"
190a8110c3dSMax Reitz$QEMU_IMG amend -o "cluster_size=1k" "$TEST_IMG"
191a8110c3dSMax Reitz$QEMU_IMG amend -o "encryption=on" "$TEST_IMG"
192a8110c3dSMax Reitz$QEMU_IMG amend -o "preallocation=on" "$TEST_IMG"
193a8110c3dSMax Reitz
194a8110c3dSMax Reitzecho
195a8110c3dSMax Reitzecho "=== Testing correct handling of unset value ==="
196a8110c3dSMax Reitzecho
197407fb56aSMax Reitz_make_test_img -o "compat=1.1,cluster_size=1k" 64M
198a8110c3dSMax Reitzecho "Should work:"
199a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
200a8110c3dSMax Reitzecho "Should not work:" # Just to know which of these tests actually fails
201a8110c3dSMax Reitz$QEMU_IMG amend -o "cluster_size=64k" "$TEST_IMG"
202a8110c3dSMax Reitz
203a8110c3dSMax Reitzecho
204a8110c3dSMax Reitzecho "=== Testing zero expansion on inactive clusters ==="
205a8110c3dSMax Reitzecho
206407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
207a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
208a8110c3dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
209a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
210a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
211a8110c3dSMax Reitz_check_test_img
212a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
213a8110c3dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
214a8110c3dSMax Reitz_check_test_img
215a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
216a8110c3dSMax Reitz
217a8110c3dSMax Reitzecho
218d982919dSMax Reitzecho "=== Testing zero expansion on shared L2 table ==="
219d982919dSMax Reitzecho
220407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
221d982919dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
222d982919dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
223d982919dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
224d982919dSMax Reitz_check_test_img
225d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
226d982919dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
227d982919dSMax Reitz_check_test_img
228d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
229d982919dSMax Reitz
230d982919dSMax Reitzecho
231a8110c3dSMax Reitzecho "=== Testing zero expansion on backed image ==="
232a8110c3dSMax Reitzecho
233407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
234a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
235b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
236a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
237a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
238a8110c3dSMax Reitz_check_test_img
239a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
240a8110c3dSMax Reitz
241a8110c3dSMax Reitzecho
242a8110c3dSMax Reitzecho "=== Testing zero expansion on backed inactive clusters ==="
243a8110c3dSMax Reitzecho
244407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
245a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
246b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
247a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
248a8110c3dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
249a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
250a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
251a8110c3dSMax Reitz_check_test_img
252a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
253a8110c3dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
254a8110c3dSMax Reitz_check_test_img
255a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
256a8110c3dSMax Reitz
257d982919dSMax Reitzecho
258d982919dSMax Reitzecho "=== Testing zero expansion on backed image with shared L2 table ==="
259d982919dSMax Reitzecho
260407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
261d982919dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
262b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
263d982919dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
264d982919dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
265d982919dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
266d982919dSMax Reitz_check_test_img
267d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
268d982919dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
269d982919dSMax Reitz_check_test_img
270d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
271d982919dSMax Reitz
272fd9e03e6SMax Reitzecho
273fd9e03e6SMax Reitzecho "=== Testing preallocated zero expansion on full image ==="
274fd9e03e6SMax Reitzecho
275407fb56aSMax ReitzTEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M
276fd9e03e6SMax Reitz$QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io
277fd9e03e6SMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
278fd9e03e6SMax Reitz_check_test_img
279fd9e03e6SMax Reitz$QEMU_IO -c "read -P 0 0 64M" "$TEST_IMG" | _filter_qemu_io
280fd9e03e6SMax Reitz
28178fa6582SMax Reitzecho
28278fa6582SMax Reitzecho "=== Testing progress report without snapshot ==="
28378fa6582SMax Reitzecho
284407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
285b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 4G
28678fa6582SMax Reitz$QEMU_IO -c "write -z 0  64k" \
28778fa6582SMax Reitz         -c "write -z 1G 64k" \
28878fa6582SMax Reitz         -c "write -z 2G 64k" \
28978fa6582SMax Reitz         -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
29078fa6582SMax Reitz$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
29178fa6582SMax Reitz_check_test_img
29278fa6582SMax Reitz
29378fa6582SMax Reitzecho
29478fa6582SMax Reitzecho "=== Testing progress report with snapshot ==="
29578fa6582SMax Reitzecho
296407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
297b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 4G
29878fa6582SMax Reitz$QEMU_IO -c "write -z 0  64k" \
29978fa6582SMax Reitz         -c "write -z 1G 64k" \
30078fa6582SMax Reitz         -c "write -z 2G 64k" \
30178fa6582SMax Reitz         -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
30278fa6582SMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
30378fa6582SMax Reitz$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
30478fa6582SMax Reitz_check_test_img
30578fa6582SMax Reitz
306ac40260dSKevin Wolfecho
307ac40260dSKevin Wolfecho "=== Testing version downgrade with external data file ==="
308ac40260dSKevin Wolfecho
309407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
310ac40260dSKevin Wolf$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
311ac40260dSKevin Wolf_img_info --format-specific
312ac40260dSKevin Wolf_check_test_img
313ac40260dSKevin Wolf
314ac40260dSKevin Wolfecho
3157bbb5920SAlberto Garciaecho "=== Testing version downgrade with extended L2 entries ==="
3167bbb5920SAlberto Garciaecho
3177bbb5920SAlberto Garcia_make_test_img -o "compat=1.1,extended_l2=on" 64M
3187bbb5920SAlberto Garcia$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
3197bbb5920SAlberto Garcia
3207bbb5920SAlberto Garciaecho
321ac40260dSKevin Wolfecho "=== Try changing the external data file ==="
322ac40260dSKevin Wolfecho
323407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
324ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
325ac40260dSKevin Wolf
326ac40260dSKevin Wolfecho
327407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
328ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
329*bd385a52SKevin Wolf$QEMU_IO -c "read 0 4k" "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
330*bd385a52SKevin Wolf$QEMU_IO -c "open -o data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" -c "read 0 4k" | _filter_qemu_io
331ac40260dSKevin WolfTEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
332ac40260dSKevin Wolf
333ac40260dSKevin Wolfecho
334ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=" --image-opts "data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG"
335*bd385a52SKevin Wolf$QEMU_IO -c "read 0 4k" "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
336*bd385a52SKevin Wolf$QEMU_IO -c "open -o data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" -c "read 0 4k" | _filter_qemu_io
337ac40260dSKevin WolfTEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
338ac40260dSKevin Wolf
339ac40260dSKevin Wolfecho
340ac40260dSKevin Wolfecho "=== Clearing and setting data-file-raw ==="
341ac40260dSKevin Wolfecho
342407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M
343ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
344ac40260dSKevin Wolf_img_info --format-specific
345ac40260dSKevin Wolf_check_test_img
346ac40260dSKevin Wolf
347ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=off" "$TEST_IMG"
348ac40260dSKevin Wolf_img_info --format-specific
349ac40260dSKevin Wolf_check_test_img
350ac40260dSKevin Wolf
351ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
352ac40260dSKevin Wolf_img_info --format-specific
353ac40260dSKevin Wolf_check_test_img
354ac40260dSKevin Wolf
355ac40260dSKevin Wolf
356a8110c3dSMax Reitz# success, all done
357a8110c3dSMax Reitzecho "*** done"
358a8110c3dSMax Reitzrm -f $seq.full
359a8110c3dSMax Reitzstatus=0
360