3 # qcow2 specific bdrv_pwrite_zeroes tests with backing files (complements 034)
5 # Copyright (C) 2016-2017 Red Hat, Inc.
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.
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.
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/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
28 status
=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
45 size
=$
((128 * 1024 * 1024))
47 # This test requires zero clusters, added in v3 images
48 _unsupported_imgopts compat
=0.10
51 echo == backing
file contains zeros
==
53 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
54 _make_test_img
-b "$TEST_IMG.base"
56 # Make sure that the whole cluster is allocated even for partial write_zeroes
57 # when the backing file contains zeros
59 # X = non-zero data sector in backing file
60 # - = sector unallocated in whole backing chain
61 # 0 = sector touched by write_zeroes request
63 # 1. Tail unaligned: 00 00 -- --
64 # 2. Head unaligned: -- -- 00 00
65 # 3. Both unaligned: -- 00 00 --
66 # 4. Both, 2 clusters: -- -- -- 00 | 00 -- -- --
68 $QEMU_IO -c "write -z 0 2k" "$TEST_IMG" | _filter_qemu_io
69 $QEMU_IO -c "write -z 10k 2k" "$TEST_IMG" | _filter_qemu_io
70 $QEMU_IO -c "write -z 17k 2k" "$TEST_IMG" | _filter_qemu_io
71 $QEMU_IO -c "write -z 27k 2k" "$TEST_IMG" | _filter_qemu_io
72 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
75 echo == backing
file contains non-zero data before write_zeroes
==
77 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
78 _make_test_img
-b "$TEST_IMG.base"
80 # Single cluster; non-zero data at the cluster start
81 # ... | XX -- 00 -- | ...
82 $QEMU_IO -c "write -P 0x11 32k 1k" "$TEST_IMG.base" | _filter_qemu_io
83 $QEMU_IO -c "write -z 34k 1k" "$TEST_IMG" | _filter_qemu_io
84 $QEMU_IO -c "read -P 0x11 32k 1k" "$TEST_IMG" | _filter_qemu_io
85 $QEMU_IO -c "read -P 0 33k 3k" "$TEST_IMG" | _filter_qemu_io
87 # Single cluster; non-zero data exists, but not at the cluster start
88 # ... | -- XX 00 -- | ...
89 $QEMU_IO -c "write -P 0x11 65k 1k" "$TEST_IMG.base" | _filter_qemu_io
90 $QEMU_IO -c "write -z 66k 1k" "$TEST_IMG" | _filter_qemu_io
91 $QEMU_IO -c "read -P 0x11 65k 1k" "$TEST_IMG" | _filter_qemu_io
92 $QEMU_IO -c "read -P 0 64k 1k" "$TEST_IMG" | _filter_qemu_io
93 $QEMU_IO -c "read -P 0 66k 2k" "$TEST_IMG" | _filter_qemu_io
95 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
98 echo == backing
file contains non-zero data after write_zeroes
==
100 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
101 _make_test_img
-b "$TEST_IMG.base"
103 # Single cluster; non-zero data directly after request
104 # ... | -- 00 XX -- | ...
105 $QEMU_IO -c "write -P 0x11 34k 1k" "$TEST_IMG.base" | _filter_qemu_io
106 $QEMU_IO -c "write -z 33k 1k" "$TEST_IMG" | _filter_qemu_io
107 $QEMU_IO -c "read -P 0 32k 2k" "$TEST_IMG" | _filter_qemu_io
108 $QEMU_IO -c "read -P 0x11 34k 1k" "$TEST_IMG" | _filter_qemu_io
109 $QEMU_IO -c "read -P 0 35k 1k" "$TEST_IMG" | _filter_qemu_io
111 # Single cluster; non-zero data exists, but not directly after request
112 # ... | -- 00 -- XX | ...
113 $QEMU_IO -c "write -P 0x11 43k 1k" "$TEST_IMG.base" | _filter_qemu_io
114 $QEMU_IO -c "write -z 41k 1k" "$TEST_IMG" | _filter_qemu_io
115 $QEMU_IO -c "read -P 0x11 43k 1k" "$TEST_IMG" | _filter_qemu_io
116 $QEMU_IO -c "read -P 0 40k 3k" "$TEST_IMG" | _filter_qemu_io
118 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
121 echo == write_zeroes covers non-zero data
==
123 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
124 _make_test_img
-b "$TEST_IMG.base"
126 # non-zero data at front of request
127 # Backing file: -- XX -- --
128 # Active layer: -- 00 00 --
130 $QEMU_IO -c "write -P 0x11 5k 1k" "$TEST_IMG.base" | _filter_qemu_io
131 $QEMU_IO -c "write -z 5k 2k" "$TEST_IMG" | _filter_qemu_io
132 $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io
134 # non-zero data at end of request
135 # Backing file: -- -- XX --
136 # Active layer: -- 00 00 --
138 $QEMU_IO -c "write -P 0x11 14k 1k" "$TEST_IMG.base" | _filter_qemu_io
139 $QEMU_IO -c "write -z 13k 2k" "$TEST_IMG" | _filter_qemu_io
140 $QEMU_IO -c "read -P 0 12k 4k" "$TEST_IMG" | _filter_qemu_io
142 # non-zero data matches size of request
143 # Backing file: -- XX XX --
144 # Active layer: -- 00 00 --
146 $QEMU_IO -c "write -P 0x11 21k 2k" "$TEST_IMG.base" | _filter_qemu_io
147 $QEMU_IO -c "write -z 21k 2k" "$TEST_IMG" | _filter_qemu_io
148 $QEMU_IO -c "read -P 0 20k 4k" "$TEST_IMG" | _filter_qemu_io
150 # non-zero data smaller than request
151 # Backing file: -- -X X- --
152 # Active layer: -- 00 00 --
154 $QEMU_IO -c "write -P 0x11 30208 1k" "$TEST_IMG.base" | _filter_qemu_io
155 $QEMU_IO -c "write -z 29k 2k" "$TEST_IMG" | _filter_qemu_io
156 $QEMU_IO -c "read -P 0 28k 4k" "$TEST_IMG" | _filter_qemu_io
158 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
161 echo == spanning two clusters
, non-zero before request
==
163 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
164 _make_test_img
-b "$TEST_IMG.base"
166 # Two clusters; non-zero data before request:
167 # 1. At cluster start: 32k: XX -- -- 00 | 00 -- -- --
168 # 2. Between unallocated space: 48k: -- XX -- 00 | 00 -- -- --
169 # 3. Directly before request: 64k: -- -- XX 00 | 00 -- -- --
171 $QEMU_IO -c "write -P 0x11 32k 1k" "$TEST_IMG.base" | _filter_qemu_io
172 $QEMU_IO -c "write -z 35k 2k" "$TEST_IMG" | _filter_qemu_io
173 $QEMU_IO -c "read -P 0x11 32k 1k" "$TEST_IMG" | _filter_qemu_io
174 $QEMU_IO -c "read -P 0 33k 7k" "$TEST_IMG" | _filter_qemu_io
176 $QEMU_IO -c "write -P 0x11 49k 1k" "$TEST_IMG.base" | _filter_qemu_io
177 $QEMU_IO -c "write -z 51k 2k" "$TEST_IMG" | _filter_qemu_io
178 $QEMU_IO -c "read -P 0 48k 1k" "$TEST_IMG" | _filter_qemu_io
179 $QEMU_IO -c "read -P 0x11 49k 1k" "$TEST_IMG" | _filter_qemu_io
180 $QEMU_IO -c "read -P 0 50k 6k" "$TEST_IMG" | _filter_qemu_io
182 $QEMU_IO -c "write -P 0x11 66k 1k" "$TEST_IMG.base" | _filter_qemu_io
183 $QEMU_IO -c "write -z 67k 2k" "$TEST_IMG" | _filter_qemu_io
184 $QEMU_IO -c "read -P 0 64k 2k" "$TEST_IMG" | _filter_qemu_io
185 $QEMU_IO -c "read -P 0x11 66k 1k" "$TEST_IMG" | _filter_qemu_io
186 $QEMU_IO -c "read -P 0 67k 5k" "$TEST_IMG" | _filter_qemu_io
188 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
191 echo == spanning two clusters
, non-zero after request
==
193 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
194 _make_test_img
-b "$TEST_IMG.base"
196 # Two clusters; non-zero data after request:
197 # 1. Directly after request: 32k: -- -- -- 00 | 00 XX -- --
198 # 2. Between unallocated space: 48k: -- -- -- 00 | 00 -- XX --
199 # 3. At cluster end: 64k: -- -- -- 00 | 00 -- -- XX
201 $QEMU_IO -c "write -P 0x11 37k 1k" "$TEST_IMG.base" | _filter_qemu_io
202 $QEMU_IO -c "write -z 35k 2k" "$TEST_IMG" | _filter_qemu_io
203 $QEMU_IO -c "read -P 0 32k 5k" "$TEST_IMG" | _filter_qemu_io
204 $QEMU_IO -c "read -P 0x11 37k 1k" "$TEST_IMG" | _filter_qemu_io
205 $QEMU_IO -c "read -P 0 38k 2k" "$TEST_IMG" | _filter_qemu_io
207 $QEMU_IO -c "write -P 0x11 54k 1k" "$TEST_IMG.base" | _filter_qemu_io
208 $QEMU_IO -c "write -z 51k 2k" "$TEST_IMG" | _filter_qemu_io
209 $QEMU_IO -c "read -P 0 48k 6k" "$TEST_IMG" | _filter_qemu_io
210 $QEMU_IO -c "read -P 0x11 54k 1k" "$TEST_IMG" | _filter_qemu_io
211 $QEMU_IO -c "read -P 0 55k 1k" "$TEST_IMG" | _filter_qemu_io
213 $QEMU_IO -c "write -P 0x11 71k 1k" "$TEST_IMG.base" | _filter_qemu_io
214 $QEMU_IO -c "write -z 67k 2k" "$TEST_IMG" | _filter_qemu_io
215 $QEMU_IO -c "read -P 0 64k 7k" "$TEST_IMG" | _filter_qemu_io
216 $QEMU_IO -c "read -P 0x11 71k 1k" "$TEST_IMG" | _filter_qemu_io
218 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
221 echo == spanning two clusters
, partially overwriting backing
file ==
223 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
224 _make_test_img
-b "$TEST_IMG.base"
226 # Backing file: -- -- XX XX | XX XX -- --
227 # Active layer: -- -- XX 00 | 00 XX -- --
229 $QEMU_IO -c "write -P 0x11 2k 4k" "$TEST_IMG.base" | _filter_qemu_io
230 $QEMU_IO -c "write -z 3k 2k" "$TEST_IMG" | _filter_qemu_io
231 $QEMU_IO -c "read -P 0 0k 2k" "$TEST_IMG" | _filter_qemu_io
232 $QEMU_IO -c "read -P 0x11 2k 1k" "$TEST_IMG" | _filter_qemu_io
233 $QEMU_IO -c "read -P 0 3k 2k" "$TEST_IMG" | _filter_qemu_io
234 $QEMU_IO -c "read -P 0x11 5k 1k" "$TEST_IMG" | _filter_qemu_io
235 $QEMU_IO -c "read -P 0 6k 2k" "$TEST_IMG" | _filter_qemu_io
237 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
240 echo == spanning multiple clusters
, non-zero
in first cluster
==
242 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
243 _make_test_img
-b "$TEST_IMG.base"
245 # Backing file: 64k: XX XX -- -- | -- -- -- -- | -- -- -- --
246 # Active layer: 64k: XX XX 00 00 | 00 00 00 00 | 00 -- -- --
248 $QEMU_IO -c "write -P 0x11 64k 2k" "$TEST_IMG.base" | _filter_qemu_io
249 $QEMU_IO -c "write -z 66k 7k" "$TEST_IMG" | _filter_qemu_io
250 $QEMU_IO -c "read -P 0x11 64k 2k" "$TEST_IMG" | _filter_qemu_io
251 $QEMU_IO -c "read -P 0 66k 10k" "$TEST_IMG" | _filter_qemu_io
253 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
256 echo == spanning multiple clusters
, non-zero
in intermediate cluster
==
258 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
259 _make_test_img
-b "$TEST_IMG.base"
261 # Backing file: 64k: -- -- -- -- | -- XX XX -- | -- -- -- --
262 # Active layer: 64k: -- -- 00 00 | 00 00 00 00 | 00 -- -- --
264 $QEMU_IO -c "write -P 0x11 69k 2k" "$TEST_IMG.base" | _filter_qemu_io
265 $QEMU_IO -c "write -z 66k 7k" "$TEST_IMG" | _filter_qemu_io
266 $QEMU_IO -c "read -P 0 64k 12k" "$TEST_IMG" | _filter_qemu_io
268 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
271 echo == spanning multiple clusters
, non-zero
in final cluster
==
273 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
274 _make_test_img
-b "$TEST_IMG.base"
276 # Backing file: 64k: -- -- -- -- | -- -- -- -- | -- -- XX XX
277 # Active layer: 64k: -- -- 00 00 | 00 00 00 00 | 00 -- XX XX
279 $QEMU_IO -c "write -P 0x11 74k 2k" "$TEST_IMG.base" | _filter_qemu_io
280 $QEMU_IO -c "write -z 66k 7k" "$TEST_IMG" | _filter_qemu_io
281 $QEMU_IO -c "read -P 0 64k 10k" "$TEST_IMG" | _filter_qemu_io
282 $QEMU_IO -c "read -P 0x11 74k 2k" "$TEST_IMG" | _filter_qemu_io
284 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
287 echo == spanning multiple clusters
, partially overwriting backing
file ==
289 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img
$size
290 _make_test_img
-b "$TEST_IMG.base"
292 # Backing file: 64k: -- XX XX XX | XX XX XX XX | XX XX XX --
293 # Active layer: 64k: -- XX 00 00 | 00 00 00 00 | 00 XX XX --
295 $QEMU_IO -c "write -P 0x11 65k 10k" "$TEST_IMG.base" | _filter_qemu_io
296 $QEMU_IO -c "write -z 66k 7k" "$TEST_IMG" | _filter_qemu_io
297 $QEMU_IO -c "read -P 0 64k 1k" "$TEST_IMG" | _filter_qemu_io
298 $QEMU_IO -c "read -P 0x11 65k 1k" "$TEST_IMG" | _filter_qemu_io
299 $QEMU_IO -c "read -P 0 66k 7k" "$TEST_IMG" | _filter_qemu_io
300 $QEMU_IO -c "read -P 0x11 73k 2k" "$TEST_IMG" | _filter_qemu_io
301 $QEMU_IO -c "read -P 0 75k 1k" "$TEST_IMG" | _filter_qemu_io
303 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
306 echo == unaligned image
tail cluster
, no allocation needed
==
308 # With no backing file, write to all or part of unallocated partial cluster
309 # will mark the cluster as zero, but does not allocate.
310 # Re-create the image each time to get back to unallocated clusters.
312 # Write at the front: sector-wise, the request is: 128m... | 00 -- -- --
313 _make_test_img $
((size
+ 2048))
314 $QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io
315 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
316 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
318 # Write at the back: sector-wise, the request is: 128m... | -- -- -- 00
319 _make_test_img $
((size
+ 2048))
320 $QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io
321 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
322 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
324 # Write at middle: sector-wise, the request is: 128m... | -- 00 00 --
325 _make_test_img $
((size
+ 2048))
326 $QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io
327 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
328 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
330 # Write entire cluster: sector-wise, the request is: 128m... | 00 00 00 00
331 _make_test_img $
((size
+ 2048))
332 $QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io
333 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
334 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
336 # Repeat with backing file holding unallocated cluster.
337 CLUSTER_SIZE
=2048 TEST_IMG
="$TEST_IMG.base" _make_test_img $
((size
+ 1024))
339 # Write at the front: sector-wise, the request is:
340 # backing: 128m... | -- --
341 # active: 128m... | 00 -- -- --
342 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
343 $QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io
344 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
345 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
347 # Write at the back: sector-wise, the request is:
348 # backing: 128m... | -- --
349 # active: 128m... | -- -- -- 00
350 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
351 $QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io
352 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
353 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
355 # Write at middle: sector-wise, the request is:
356 # backing: 128m... | -- --
357 # active: 128m... | -- 00 00 --
358 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
359 $QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io
360 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
361 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
363 # Write entire cluster: sector-wise, the request is:
364 # backing: 128m... | -- --
365 # active: 128m... | 00 00 00 00
366 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
367 $QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io
368 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
369 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
371 # Repeat with backing file holding zero'd cluster
372 $QEMU_IO -c "write -z $size 512" "$TEST_IMG.base" | _filter_qemu_io
374 # Write at the front: sector-wise, the request is:
375 # backing: 128m... | 00 00
376 # active: 128m... | 00 -- -- --
377 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
378 $QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io
379 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
380 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
382 # Write at the back: sector-wise, the request is:
383 # backing: 128m... | 00 00
384 # active: 128m... | -- -- -- 00
385 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
386 $QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io
387 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
388 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
390 # Write at middle: sector-wise, the request is:
391 # backing: 128m... | 00 00
392 # active: 128m... | -- 00 00 --
393 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
394 $QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io
395 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
396 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
398 # Write entire cluster: sector-wise, the request is:
399 # backing: 128m... | 00 00
400 # active: 128m... | 00 00 00 00
401 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
402 $QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io
403 $QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io
404 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
406 # A preallocated cluster maintains its allocation, whether it stays as
407 # data due to a partial write:
408 # Convert 128m... | XX XX => ... | XX 00
409 _make_test_img $
((size
+ 1024))
410 $QEMU_IO -c "write -P 1 $((size)) 1024" "$TEST_IMG" | _filter_qemu_io
411 $QEMU_IO -c "write -z $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io
412 $QEMU_IO -c "read -P 1 $((size)) 512" "$TEST_IMG" | _filter_qemu_io
413 $QEMU_IO -c "read -P 0 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io
414 $QEMU_IO -c "alloc $size 1024" "$TEST_IMG" | _filter_qemu_io
415 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
417 # or because it is the entire cluster and can use the zero flag:
418 # Convert 128m... | XX XX => ... | 00 00
419 $QEMU_IO -c "write -z $((size)) 1024" "$TEST_IMG" | _filter_qemu_io
420 $QEMU_IO -c "alloc $size 1024" "$TEST_IMG" | _filter_qemu_io
421 $QEMU_IO -c "read -P 0 $size 1024" "$TEST_IMG" | _filter_qemu_io
422 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
425 echo == unaligned image
tail cluster
, allocation required
==
427 # Write beyond backing file must COW
428 # Backing file: 128m... | XX --
429 # Active layer: 128m... | -- -- 00 --
430 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img $
((size
+ 1024))
431 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
432 $QEMU_IO -c "write -P 1 $((size)) 512" "$TEST_IMG.base" | _filter_qemu_io
433 $QEMU_IO -c "write -z $((size + 1024)) 512" "$TEST_IMG" | _filter_qemu_io
434 $QEMU_IO -c "read -P 1 $((size)) 512" "$TEST_IMG" | _filter_qemu_io
435 $QEMU_IO -c "read -P 0 $((size + 512)) 1536" "$TEST_IMG" | _filter_qemu_io
436 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
438 # Writes at boundaries of (partial) cluster must not lose mid-cluster data
439 # Backing file: 128m: ... | -- XX
440 # Active layer: 128m: ... | 00 -- -- 00
441 CLUSTER_SIZE
=512 TEST_IMG
="$TEST_IMG.base" _make_test_img $
((size
+ 1024))
442 _make_test_img
-b "$TEST_IMG.base" $
((size
+ 2048))
443 $QEMU_IO -c "write -P 1 $((size + 512)) 512" "$TEST_IMG.base" | _filter_qemu_io
444 $QEMU_IO -c "write -z $((size)) 512" "$TEST_IMG" | _filter_qemu_io
445 $QEMU_IO -c "read -P 0 $((size)) 512" "$TEST_IMG" | _filter_qemu_io
446 $QEMU_IO -c "read -P 1 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io
447 $QEMU_IO -c "read -P 0 $((size + 1024)) 1024" "$TEST_IMG" | _filter_qemu_io
448 $QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io
449 $QEMU_IO -c "read -P 0 $((size)) 512" "$TEST_IMG" | _filter_qemu_io
450 $QEMU_IO -c "read -P 1 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io
451 $QEMU_IO -c "read -P 0 $((size + 1024)) 1024" "$TEST_IMG" | _filter_qemu_io
452 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map