xref: /openbmc/qemu/tests/qemu-iotests/061 (revision 9dd003a9)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir 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
23a8110c3dSMax Reitzowner=mreitz@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
51e7be13adSEric Blake_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file cluster_size
52a8110c3dSMax Reitz
53a8110c3dSMax Reitzecho
54a8110c3dSMax Reitzecho "=== Testing version downgrade with zero expansion ==="
55a8110c3dSMax Reitzecho
56407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
57a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
58ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
59a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
60ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
61a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
62a8110c3dSMax Reitz_check_test_img
63a8110c3dSMax Reitz
64a8110c3dSMax Reitzecho
652ecec911SAlberto Garciaecho "=== Testing version downgrade with zero expansion and 4K cache entries ==="
662ecec911SAlberto Garciaecho
67407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
682ecec911SAlberto Garcia$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
692ecec911SAlberto Garcia$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io
702ecec911SAlberto Garcia$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
712ecec911SAlberto Garcia$PYTHON qcow2.py "$TEST_IMG" dump-header
722ecec911SAlberto Garcia$QEMU_IMG amend -o "compat=0.10" --image-opts \
732ecec911SAlberto Garcia          driver=qcow2,file.filename=$TEST_IMG,l2-cache-entry-size=4096
742ecec911SAlberto Garcia$PYTHON qcow2.py "$TEST_IMG" dump-header
752ecec911SAlberto Garcia$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
762ecec911SAlberto Garcia$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io
772ecec911SAlberto Garcia$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
782ecec911SAlberto Garcia_check_test_img
792ecec911SAlberto Garcia
802ecec911SAlberto Garciaecho
81a8110c3dSMax Reitzecho "=== Testing dirty version downgrade ==="
82a8110c3dSMax Reitzecho
83407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
848af224d6SAndrey Shinkevich_NO_VALGRIND \
85efd0fbbcSAlberto Garcia$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
86efd0fbbcSAlberto Garcia         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
87ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
88a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
89ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
90a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
91a8110c3dSMax Reitz_check_test_img
92a8110c3dSMax Reitz
93a8110c3dSMax Reitzecho
94a8110c3dSMax Reitzecho "=== Testing version downgrade with unknown compat/autoclear flags ==="
95a8110c3dSMax Reitzecho
96407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
97ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42
98ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42
99ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
100a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
101ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
102a8110c3dSMax Reitz_check_test_img
103a8110c3dSMax Reitz
104a8110c3dSMax Reitzecho
105a8110c3dSMax Reitzecho "=== Testing version upgrade and resize ==="
106a8110c3dSMax Reitzecho
107407fb56aSMax Reitz_make_test_img -o "compat=0.10" 64M
108a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
109ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
110a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG"
111ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
112a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
113a8110c3dSMax Reitz_check_test_img
114a8110c3dSMax Reitz
115a8110c3dSMax Reitzecho
1167fa140abSEric Blakeecho "=== Testing resize with snapshots ==="
1177fa140abSEric Blakeecho
1187fa140abSEric Blake_make_test_img -o "compat=0.10" 32M
1197fa140abSEric Blake$QEMU_IO -c "write -P 0x2a 24M 64k" "$TEST_IMG" | _filter_qemu_io
1207fa140abSEric Blake$QEMU_IMG snapshot -c foo "$TEST_IMG"
1217fa140abSEric Blake$QEMU_IMG resize "$TEST_IMG" 64M &&
1227fa140abSEric Blake    echo "unexpected pass"
1237fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1247fa140abSEric Blake
1257fa140abSEric Blake$QEMU_IMG amend -o "compat=1.1,size=128M" "$TEST_IMG" ||
1267fa140abSEric Blake    echo "unexpected fail"
1277fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1287fa140abSEric Blake
1297fa140abSEric Blake$QEMU_IMG snapshot -c bar "$TEST_IMG"
1307fa140abSEric Blake$QEMU_IMG resize --shrink "$TEST_IMG" 64M ||
1317fa140abSEric Blake    echo "unexpected fail"
1327fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1337fa140abSEric Blake
1347fa140abSEric Blake$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" &&
1357fa140abSEric Blake    echo "unexpected pass"
1367fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1377fa140abSEric Blake
1387fa140abSEric Blake$QEMU_IMG snapshot -a bar "$TEST_IMG" ||
1397fa140abSEric Blake    echo "unexpected fail"
1407fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1417fa140abSEric Blake
1427fa140abSEric Blake$QEMU_IMG snapshot -d bar "$TEST_IMG"
1437fa140abSEric Blake$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" ||
1447fa140abSEric Blake    echo "unexpected fail"
1457fa140abSEric Blake$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
1467fa140abSEric Blake
1477fa140abSEric Blake_check_test_img
1487fa140abSEric Blake
1497fa140abSEric Blake
1507fa140abSEric Blakeecho
151a8110c3dSMax Reitzecho "=== Testing dirty lazy_refcounts=off ==="
152a8110c3dSMax Reitzecho
153407fb56aSMax Reitz_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
1548af224d6SAndrey Shinkevich_NO_VALGRIND \
155efd0fbbcSAlberto Garcia$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
156efd0fbbcSAlberto Garcia         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
157ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
158a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG"
159ea81ca9dSMax Reitz$PYTHON qcow2.py "$TEST_IMG" dump-header
160a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
161a8110c3dSMax Reitz_check_test_img
162a8110c3dSMax Reitz
163a8110c3dSMax Reitzecho
164a8110c3dSMax Reitzecho "=== Testing backing file ==="
165a8110c3dSMax Reitzecho
166407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
167407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
168a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
169a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
170a8110c3dSMax Reitz$QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG"
171a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
172a8110c3dSMax Reitz_check_test_img
173a8110c3dSMax Reitz
174a8110c3dSMax Reitzecho
175a8110c3dSMax Reitzecho "=== Testing invalid configurations ==="
176a8110c3dSMax Reitzecho
177407fb56aSMax Reitz_make_test_img -o "compat=0.10" 64M
178a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
179a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid
180a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG"
181a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.42" "$TEST_IMG"
182a8110c3dSMax Reitz$QEMU_IMG amend -o "foo=bar" "$TEST_IMG"
183a8110c3dSMax Reitz$QEMU_IMG amend -o "cluster_size=1k" "$TEST_IMG"
184a8110c3dSMax Reitz$QEMU_IMG amend -o "encryption=on" "$TEST_IMG"
185a8110c3dSMax Reitz$QEMU_IMG amend -o "preallocation=on" "$TEST_IMG"
186a8110c3dSMax Reitz
187a8110c3dSMax Reitzecho
188a8110c3dSMax Reitzecho "=== Testing correct handling of unset value ==="
189a8110c3dSMax Reitzecho
190407fb56aSMax Reitz_make_test_img -o "compat=1.1,cluster_size=1k" 64M
191a8110c3dSMax Reitzecho "Should work:"
192a8110c3dSMax Reitz$QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG"
193a8110c3dSMax Reitzecho "Should not work:" # Just to know which of these tests actually fails
194a8110c3dSMax Reitz$QEMU_IMG amend -o "cluster_size=64k" "$TEST_IMG"
195a8110c3dSMax Reitz
196a8110c3dSMax Reitzecho
197a8110c3dSMax Reitzecho "=== Testing zero expansion on inactive clusters ==="
198a8110c3dSMax Reitzecho
199407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
200a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
201a8110c3dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
202a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
203a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
204a8110c3dSMax Reitz_check_test_img
205a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
206a8110c3dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
207a8110c3dSMax Reitz_check_test_img
208a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
209a8110c3dSMax Reitz
210a8110c3dSMax Reitzecho
211d982919dSMax Reitzecho "=== Testing zero expansion on shared L2 table ==="
212d982919dSMax Reitzecho
213407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
214d982919dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
215d982919dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
216d982919dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
217d982919dSMax Reitz_check_test_img
218d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
219d982919dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
220d982919dSMax Reitz_check_test_img
221d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
222d982919dSMax Reitz
223d982919dSMax Reitzecho
224a8110c3dSMax Reitzecho "=== Testing zero expansion on backed image ==="
225a8110c3dSMax Reitzecho
226407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
227a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
228b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
229a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
230a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
231a8110c3dSMax Reitz_check_test_img
232a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
233a8110c3dSMax Reitz
234a8110c3dSMax Reitzecho
235a8110c3dSMax Reitzecho "=== Testing zero expansion on backed inactive clusters ==="
236a8110c3dSMax Reitzecho
237407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
238a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
239b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
240a8110c3dSMax Reitz$QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io
241a8110c3dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
242a8110c3dSMax Reitz$QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
243a8110c3dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
244a8110c3dSMax Reitz_check_test_img
245a8110c3dSMax Reitz$QEMU_IO -c "read -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io
246a8110c3dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
247a8110c3dSMax Reitz_check_test_img
248a8110c3dSMax Reitz$QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qemu_io
249a8110c3dSMax Reitz
250d982919dSMax Reitzecho
251d982919dSMax Reitzecho "=== Testing zero expansion on backed image with shared L2 table ==="
252d982919dSMax Reitzecho
253407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M
254d982919dSMax Reitz$QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io
255b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 64M
256d982919dSMax Reitz$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
257d982919dSMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
258d982919dSMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
259d982919dSMax Reitz_check_test_img
260d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
261d982919dSMax Reitz$QEMU_IMG snapshot -a foo "$TEST_IMG"
262d982919dSMax Reitz_check_test_img
263d982919dSMax Reitz$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
264d982919dSMax Reitz
265fd9e03e6SMax Reitzecho
266fd9e03e6SMax Reitzecho "=== Testing preallocated zero expansion on full image ==="
267fd9e03e6SMax Reitzecho
268407fb56aSMax ReitzTEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M
269fd9e03e6SMax Reitz$QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io
270fd9e03e6SMax Reitz$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
271fd9e03e6SMax Reitz_check_test_img
272fd9e03e6SMax Reitz$QEMU_IO -c "read -P 0 0 64M" "$TEST_IMG" | _filter_qemu_io
273fd9e03e6SMax Reitz
27478fa6582SMax Reitzecho
27578fa6582SMax Reitzecho "=== Testing progress report without snapshot ==="
27678fa6582SMax Reitzecho
277407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
278b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 4G
27978fa6582SMax Reitz$QEMU_IO -c "write -z 0  64k" \
28078fa6582SMax Reitz         -c "write -z 1G 64k" \
28178fa6582SMax Reitz         -c "write -z 2G 64k" \
28278fa6582SMax Reitz         -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
28378fa6582SMax Reitz$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
28478fa6582SMax Reitz_check_test_img
28578fa6582SMax Reitz
28678fa6582SMax Reitzecho
28778fa6582SMax Reitzecho "=== Testing progress report with snapshot ==="
28878fa6582SMax Reitzecho
289407fb56aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G
290b66ff2c2SEric Blake_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" -F $IMGFMT 4G
29178fa6582SMax Reitz$QEMU_IO -c "write -z 0  64k" \
29278fa6582SMax Reitz         -c "write -z 1G 64k" \
29378fa6582SMax Reitz         -c "write -z 2G 64k" \
29478fa6582SMax Reitz         -c "write -z 3G 64k" "$TEST_IMG" | _filter_qemu_io
29578fa6582SMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
29678fa6582SMax Reitz$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
29778fa6582SMax Reitz_check_test_img
29878fa6582SMax Reitz
299ac40260dSKevin Wolfecho
300ac40260dSKevin Wolfecho "=== Testing version downgrade with external data file ==="
301ac40260dSKevin Wolfecho
302407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
303ac40260dSKevin Wolf$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
304ac40260dSKevin Wolf_img_info --format-specific
305ac40260dSKevin Wolf_check_test_img
306ac40260dSKevin Wolf
307ac40260dSKevin Wolfecho
3087bbb5920SAlberto Garciaecho "=== Testing version downgrade with extended L2 entries ==="
3097bbb5920SAlberto Garciaecho
3107bbb5920SAlberto Garcia_make_test_img -o "compat=1.1,extended_l2=on" 64M
3117bbb5920SAlberto Garcia$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
3127bbb5920SAlberto Garcia
3137bbb5920SAlberto Garciaecho
314ac40260dSKevin Wolfecho "=== Try changing the external data file ==="
315ac40260dSKevin Wolfecho
316407fb56aSMax Reitz_make_test_img -o "compat=1.1" 64M
317ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
318ac40260dSKevin Wolf
319ac40260dSKevin Wolfecho
320407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M
321ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
322ac40260dSKevin Wolf_img_info --format-specific
323ac40260dSKevin WolfTEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
324ac40260dSKevin Wolf
325ac40260dSKevin Wolfecho
326ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file=" --image-opts "data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG"
327ac40260dSKevin Wolf_img_info --format-specific
328ac40260dSKevin WolfTEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
329ac40260dSKevin Wolf
330ac40260dSKevin Wolfecho
331ac40260dSKevin Wolfecho "=== Clearing and setting data-file-raw ==="
332ac40260dSKevin Wolfecho
333407fb56aSMax Reitz_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M
334ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
335ac40260dSKevin Wolf_img_info --format-specific
336ac40260dSKevin Wolf_check_test_img
337ac40260dSKevin Wolf
338ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=off" "$TEST_IMG"
339ac40260dSKevin Wolf_img_info --format-specific
340ac40260dSKevin Wolf_check_test_img
341ac40260dSKevin Wolf
342ac40260dSKevin Wolf$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
343ac40260dSKevin Wolf_img_info --format-specific
344ac40260dSKevin Wolf_check_test_img
345ac40260dSKevin Wolf
346ac40260dSKevin Wolf
347a8110c3dSMax Reitz# success, all done
348a8110c3dSMax Reitzecho "*** done"
349a8110c3dSMax Reitzrm -f $seq.full
350a8110c3dSMax Reitzstatus=0
351