]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
231f66d2 KW |
2 | # |
3 | # Test qcow2 reopen | |
4 | # | |
5 | # Copyright (C) 2015 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 | owner=kwolf@redhat.com | |
23 | ||
24 | seq="$(basename $0)" | |
25 | echo "QA output created by $seq" | |
26 | ||
231f66d2 KW |
27 | status=1 # failure is the default! |
28 | ||
29 | _cleanup() | |
30 | { | |
31 | _cleanup_test_img | |
32 | } | |
33 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
34 | ||
35 | # get standard environment, filters and checks | |
36 | . ./common.rc | |
37 | . ./common.filter | |
38 | . ./common.qemu | |
39 | ||
40 | _supported_fmt qcow2 | |
2b12baf0 | 41 | _supported_proto file |
231f66d2 | 42 | _supported_os Linux |
94254c9b HR |
43 | # We are going to use lazy-refcounts |
44 | _unsupported_imgopts 'compat=0.10' | |
231f66d2 KW |
45 | |
46 | ||
47 | _make_test_img 64M | |
48 | ||
49 | echo === Try setting valid values for all options === | |
50 | echo | |
51 | ||
52 | # Try all options and then check that all of the basic I/O operations still | |
53 | # work on this image. | |
54 | $QEMU_IO \ | |
55 | -c "reopen -o lazy-refcounts=on,pass-discard-request=on" \ | |
56 | -c "reopen -o lazy-refcounts=off,pass-discard-request=off" \ | |
57 | -c "reopen -o pass-discard-snapshot=on,pass-discard-other=on" \ | |
58 | -c "reopen -o pass-discard-snapshot=off,pass-discard-other=off" \ | |
59 | -c "reopen -o overlap-check=all" \ | |
60 | -c "reopen -o overlap-check=none" \ | |
61 | -c "reopen -o overlap-check=cached" \ | |
62 | -c "reopen -o overlap-check=constant" \ | |
63 | -c "reopen -o overlap-check.template=all" \ | |
64 | -c "reopen -o overlap-check.template=none" \ | |
65 | -c "reopen -o overlap-check.template=cached" \ | |
66 | -c "reopen -o overlap-check.template=constant" \ | |
67 | -c "reopen -o overlap-check.main-header=on" \ | |
68 | -c "reopen -o overlap-check.main-header=off" \ | |
69 | -c "reopen -o overlap-check.active-l1=on" \ | |
70 | -c "reopen -o overlap-check.active-l1=off" \ | |
71 | -c "reopen -o overlap-check.active-l2=on" \ | |
72 | -c "reopen -o overlap-check.active-l2=off" \ | |
73 | -c "reopen -o overlap-check.refcount-table=on" \ | |
74 | -c "reopen -o overlap-check.refcount-table=off" \ | |
75 | -c "reopen -o overlap-check.refcount-block=on" \ | |
76 | -c "reopen -o overlap-check.refcount-block=off" \ | |
77 | -c "reopen -o overlap-check.snapshot-table=on" \ | |
78 | -c "reopen -o overlap-check.snapshot-table=off" \ | |
79 | -c "reopen -o overlap-check.inactive-l1=on" \ | |
80 | -c "reopen -o overlap-check.inactive-l1=off" \ | |
81 | -c "reopen -o overlap-check.inactive-l2=on" \ | |
82 | -c "reopen -o overlap-check.inactive-l2=off" \ | |
83 | -c "reopen -o cache-size=1M" \ | |
84 | -c "reopen -o l2-cache-size=512k" \ | |
03b1b6f0 AG |
85 | -c "reopen -o l2-cache-entry-size=512" \ |
86 | -c "reopen -o l2-cache-entry-size=4k" \ | |
87 | -c "reopen -o l2-cache-entry-size=64k" \ | |
231f66d2 KW |
88 | -c "reopen -o refcount-cache-size=128k" \ |
89 | -c "reopen -o cache-clean-interval=5" \ | |
90 | -c "reopen -o cache-clean-interval=0" \ | |
91 | -c "reopen -o cache-clean-interval=10" \ | |
92 | \ | |
93 | -c "write -P 55 0 32M" \ | |
94 | -c "read -P 55 0 32M" \ | |
95 | -c "discard 0 32M" \ | |
96 | -c "write -z 0 32M" \ | |
97 | -c "read -P 0 0 32M" \ | |
98 | \ | |
99 | "$TEST_IMG" | _filter_qemu_io | |
100 | ||
101 | ||
102 | echo | |
103 | echo === Try setting some invalid values === | |
104 | echo | |
105 | ||
106 | $QEMU_IO \ | |
107 | -c "reopen -o lazy-refcounts=42" \ | |
108 | -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ | |
109 | -c "reopen -o cache-size=1M,l2-cache-size=2M" \ | |
110 | -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ | |
03b1b6f0 AG |
111 | -c "reopen -o l2-cache-entry-size=33k" \ |
112 | -c "reopen -o l2-cache-entry-size=128k" \ | |
231f66d2 KW |
113 | -c "reopen -o refcount-cache-size=256T" \ |
114 | -c "reopen -o overlap-check=constant,overlap-check.template=all" \ | |
115 | -c "reopen -o overlap-check=blubb" \ | |
116 | -c "reopen -o overlap-check.template=blubb" \ | |
117 | -c "reopen -o cache-clean-interval=-1" \ | |
118 | "$TEST_IMG" | _filter_qemu_io | |
119 | ||
b749562d LB |
120 | IMGOPTS="cluster_size=256k" _make_test_img 32P |
121 | $QEMU_IO \ | |
122 | -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ | |
123 | "$TEST_IMG" | _filter_qemu_io | |
124 | ||
125 | _make_test_img 64M | |
126 | ||
231f66d2 KW |
127 | echo |
128 | echo === Test transaction semantics === | |
129 | echo | |
130 | ||
131 | # Whether lazy-refcounts was actually enabled can easily be tested: Check if | |
132 | # the dirty bit is set after a crash | |
133 | $QEMU_IO \ | |
134 | -c "reopen -o lazy-refcounts=on,overlap-check=blubb" \ | |
135 | -c "write -P 0x5a 0 512" \ | |
136 | -c "sigraise $(kill -l KILL)" \ | |
137 | "$TEST_IMG" 2>&1 | _filter_qemu_io | |
138 | ||
139 | # The dirty bit must not be set | |
140 | $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features | |
141 | ||
142 | # Similarly we can test whether corruption detection has been enabled: | |
143 | # Create L1/L2, overwrite first entry in refcount block, allocate something. | |
144 | # Disabling the checks should fail, so the corruption must be detected. | |
145 | _make_test_img 64M | |
146 | $QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io | |
147 | poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" | |
148 | $QEMU_IO \ | |
149 | -c "reopen -o overlap-check=none,lazy-refcounts=42" \ | |
150 | -c "write 64k 64k" \ | |
151 | "$TEST_IMG" 2>&1 | _filter_qemu_io | |
152 | ||
153 | # success, all done | |
154 | echo '*** done' | |
155 | rm -f $seq.full | |
156 | status=0 |