]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/039
build: Remove --enable-gprof
[mirror_qemu.git] / tests / qemu-iotests / 039
CommitLineData
11a82d14 1#!/usr/bin/env bash
9dd003a9 2# group: rw auto quick
dc68afe0
SH
3#
4# Test qcow2 lazy refcounts
5#
6# Copyright (C) 2012 Red Hat, Inc.
7# Copyright IBM, Corp. 2010
8#
9# Based on test 038.
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24
25# creator
42a5009d 26owner=stefanha@redhat.com
dc68afe0
SH
27
28seq=`basename $0`
29echo "QA output created by $seq"
30
dc68afe0
SH
31status=1 # failure is the default!
32
33_cleanup()
34{
35 _cleanup_test_img
36}
37trap "_cleanup; exit \$status" 0 1 2 3 15
38
39# get standard environment, filters and checks
40. ./common.rc
41. ./common.filter
42
43_supported_fmt qcow2
57284d2a 44_supported_proto file fuse
dc68afe0 45_supported_os Linux
755c5fe7
NS
46_default_cache_mode writethrough
47_supported_cache_modes writethrough
3be2024a
HR
48# Some of these test cases expect no external data file so that all
49# clusters are part of the qcow2 image and refcounted
50_unsupported_imgopts data_file
dc68afe0
SH
51
52size=128M
53
54echo
55echo "== Checking that image is clean on shutdown =="
56
407fb56a 57_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
dc68afe0 58
f897e393 59$QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
dc68afe0
SH
60
61# The dirty bit must not be set
984d7a52 62_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
63_check_test_img
64
65echo
66echo "== Creating a dirty image file =="
67
407fb56a 68_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
dc68afe0 69
8af224d6 70_NO_VALGRIND \
934659c4
HR
71$QEMU_IO -c "write -P 0x5a 0 512" \
72 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
3f394472 73 | _filter_qemu_io
dc68afe0
SH
74
75# The dirty bit must be set
984d7a52 76_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
77_check_test_img
78
79echo
80echo "== Read-only access must still work =="
81
fef9c191 82$QEMU_IO -r -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
dc68afe0
SH
83
84# The dirty bit must be set
984d7a52 85_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
86
87echo
88echo "== Repairing the image file must succeed =="
89
c6bb9ad1 90_check_test_img -r all
dc68afe0
SH
91
92# The dirty bit must not be set
984d7a52 93_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
94
95echo
96echo "== Data should still be accessible after repair =="
97
fef9c191 98$QEMU_IO -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
dc68afe0
SH
99
100echo
101echo "== Opening a dirty image read/write should repair it =="
102
407fb56a 103_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
dc68afe0 104
8af224d6 105_NO_VALGRIND \
934659c4
HR
106$QEMU_IO -c "write -P 0x5a 0 512" \
107 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
3f394472 108 | _filter_qemu_io
dc68afe0
SH
109
110# The dirty bit must be set
984d7a52 111_qcow2_dump_header | grep incompatible_features
dc68afe0 112
fef9c191 113$QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io
dc68afe0
SH
114
115# The dirty bit must not be set
984d7a52 116_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
117
118echo
119echo "== Creating an image file with lazy_refcounts=off =="
120
407fb56a 121_make_test_img -o "compat=1.1,lazy_refcounts=off" $size
dc68afe0 122
8af224d6 123_NO_VALGRIND \
934659c4
HR
124$QEMU_IO -c "write -P 0x5a 0 512" \
125 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
3f394472 126 | _filter_qemu_io
dc68afe0
SH
127
128# The dirty bit must not be set since lazy_refcounts=off
984d7a52 129_qcow2_dump_header | grep incompatible_features
dc68afe0
SH
130_check_test_img
131
4c2e5f8f
KW
132echo
133echo "== Committing to a backing file with lazy_refcounts=on =="
134
407fb56a 135TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size
4c2e5f8f 136
b66ff2c2
EB
137_make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" \
138 -F $IMGFMT $size
4c2e5f8f
KW
139
140$QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io
141$QEMU_IMG commit "$TEST_IMG"
142
143# The dirty bit must not be set
984d7a52 144_qcow2_dump_header | grep incompatible_features
72be51dd 145_qcow2_dump_header "$TEST_IMG".base | grep incompatible_features
4c2e5f8f
KW
146
147_check_test_img
148TEST_IMG="$TEST_IMG".base _check_test_img
149
e615053b
KW
150echo
151echo "== Changing lazy_refcounts setting at runtime =="
152
407fb56a 153_make_test_img -o "compat=1.1,lazy_refcounts=off" $size
e615053b 154
8af224d6 155_NO_VALGRIND \
e615053b
KW
156$QEMU_IO -c "reopen -o lazy-refcounts=on" \
157 -c "write -P 0x5a 0 512" \
158 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
159 | _filter_qemu_io
160
161# The dirty bit must be set
984d7a52 162_qcow2_dump_header | grep incompatible_features
e615053b
KW
163_check_test_img
164
407fb56a 165_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
e615053b 166
8af224d6 167_NO_VALGRIND \
e615053b
KW
168$QEMU_IO -c "reopen -o lazy-refcounts=off" \
169 -c "write -P 0x5a 0 512" \
170 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
171 | _filter_qemu_io
172
173# The dirty bit must not be set
984d7a52 174_qcow2_dump_header | grep incompatible_features
e615053b
KW
175_check_test_img
176
4c2e5f8f 177
dc68afe0
SH
178# success, all done
179echo "*** done"
180rm -f $seq.full
181status=0
182