abd3622cc0
L2 entries for compressed clusters have a field that indicates the number of sectors used to store the data in the image. That's however not the size of the compressed data itself, just the number of sectors where that data is located. The actual data size is usually not a multiple of the sector size, and therefore cannot be represented with this field. The way it works is that QEMU reads all the specified sectors and starts decompressing the data until there's enough to recover the original uncompressed cluster. If there are any bytes left that haven't been decompressed they are simply ignored. One consequence of this is that even if the size field is larger than it needs to be QEMU can handle it just fine: it will read more data from disk but it will ignore the extra bytes. This test creates an image with two compressed clusters that use 5 sectors (2.5 KB) each, increases the size field to the maximum (8192 sectors, or 4 MB) and verifies that the data can be read without problems. This test is important because while the decompressed data takes exactly one cluster, the maximum value allowed in the compressed size field is twice the cluster size. So although QEMU won't produce images with such large values we need to make sure that it can handle them. Another effect of increasing the size field is that it can make it include data from the following host cluster(s). In this case 'qemu-img check' will detect that the refcounts are not correct, and we'll need to rebuild them. Additionally, this patch also tests that decreasing the size corrupts the image since the original data can no longer be recovered. In this case QEMU returns an error when trying to read the compressed data, but 'qemu-img check' doesn't see anything wrong if the refcounts are consistent. One possible task for the future is to make 'qemu-img check' verify the sizes of the compressed clusters, by trying to decompress the data and checking that the size stored in the L2 entry is correct. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 20180329120745.11154-1-berto@igalia.com Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
241 lines
11 KiB
Plaintext
241 lines
11 KiB
Plaintext
QA output created by 122
|
|
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
|
|
wrote 67108864/67108864 bytes at offset 0
|
|
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
=== Check allocation status regression with -B ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
|
|
wrote 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
Offset Length File
|
|
0 0x300000 TEST_DIR/t.IMGFMT.orig
|
|
0x300000 0x3d00000 TEST_DIR/t.IMGFMT.base
|
|
|
|
=== Check that zero clusters are kept in overlay ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
|
|
wrote 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
=== Concatenate multiple source images ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=4194304
|
|
Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=4194304
|
|
Formatting 'TEST_DIR/t.IMGFMT.3', fmt=IMGFMT size=4194304
|
|
wrote 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
Offset Length File
|
|
0 0x10000 TEST_DIR/t.IMGFMT
|
|
0x400000 0x10000 TEST_DIR/t.IMGFMT
|
|
0x800000 0x10000 TEST_DIR/t.IMGFMT
|
|
read 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 65536/65536 bytes at offset 4194304
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 65536/65536 bytes at offset 8388608
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 65536, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 65536, "length": 4128768, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 4194304, "length": 65536, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 4259840, "length": 4128768, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 8388608, "length": 65536, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 8454144, "length": 4128768, "depth": 0, "zero": true, "data": false}]
|
|
read 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 65536/65536 bytes at offset 4194304
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 65536/65536 bytes at offset 8388608
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images
|
|
qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images
|
|
|
|
=== Compression with misaligned allocations and image sizes ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=1047552
|
|
Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=1047552
|
|
wrote 16384/16384 bytes at offset 16384
|
|
16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 133120/133120 bytes at offset 133120
|
|
130 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 1024/1024 bytes at offset 1046528
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 1024/1024 bytes at offset 0
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 65536, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 65536, "length": 65536, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 131072, "length": 196608, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 327680, "length": 655360, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 1048576, "length": 1046528, "depth": 0, "zero": true, "data": false}]
|
|
read 16384/16384 bytes at offset 0
|
|
16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 16384/16384 bytes at offset 16384
|
|
16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 100352/100352 bytes at offset 32768
|
|
98 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 133120/133120 bytes at offset 133120
|
|
130 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 780288/780288 bytes at offset 266240
|
|
762 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 1024/1024 bytes at offset 1046528
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 1024/1024 bytes at offset 1047552
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 1046528/1046528 bytes at offset 1048576
|
|
1022 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
=== Corrupted size field in compressed cluster descriptor ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=8388608
|
|
wrote 2097152/2097152 bytes at offset 0
|
|
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 2097152/2097152 bytes at offset 2097152
|
|
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read failed: Input/output error
|
|
No errors were found on the image.
|
|
read 4194304/4194304 bytes at offset 0
|
|
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 4194304/4194304 bytes at offset 4194304
|
|
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 4194304/4194304 bytes at offset 0
|
|
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
ERROR cluster 6 refcount=1 reference=3
|
|
ERROR cluster 7 refcount=1 reference=2
|
|
Repairing cluster 6 refcount=1 reference=3
|
|
Repairing cluster 7 refcount=1 reference=2
|
|
Repairing OFLAG_COPIED data cluster: l2_entry=8000000000c00000 refcount=3
|
|
Repairing OFLAG_COPIED data cluster: l2_entry=8000000000e00000 refcount=2
|
|
The following inconsistencies were found and repaired:
|
|
|
|
0 leaked clusters
|
|
4 corruptions
|
|
|
|
Double checking the fixed image now...
|
|
No errors were found on the image.
|
|
read 4194304/4194304 bytes at offset 0
|
|
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 4194304/4194304 bytes at offset 4194304
|
|
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
=== Full allocation with -S 0 ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
wrote 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 3145728/3145728 bytes at offset 3145728
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
convert -S 0:
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 63963136/63963136 bytes at offset 3145728
|
|
61 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
|
convert -c -S 0:
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 63963136/63963136 bytes at offset 3145728
|
|
61 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true}]
|
|
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
|
|
wrote 33554432/33554432 bytes at offset 0
|
|
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
|
|
wrote 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
convert -S 0 with source backing file:
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 30408704/30408704 bytes at offset 3145728
|
|
29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 33554432/33554432 bytes at offset 33554432
|
|
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
|
convert -c -S 0 with source backing file:
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 30408704/30408704 bytes at offset 3145728
|
|
29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 33554432/33554432 bytes at offset 33554432
|
|
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true}]
|
|
|
|
convert -S 0 -B ...
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 30408704/30408704 bytes at offset 3145728
|
|
29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 33554432/33554432 bytes at offset 33554432
|
|
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
|
convert -c -S 0 -B ...
|
|
read 3145728/3145728 bytes at offset 0
|
|
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 30408704/30408704 bytes at offset 3145728
|
|
29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
read 33554432/33554432 bytes at offset 33554432
|
|
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true}]
|
|
|
|
=== Non-zero -S ===
|
|
|
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
wrote 65536/65536 bytes at offset 0
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 1024/1024 bytes at offset 0
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 1024/1024 bytes at offset 8192
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 1024/1024 bytes at offset 17408
|
|
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
|
convert -S 4k
|
|
[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
{ "start": 1024, "length": 7168, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 8192, "length": 1024, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
{ "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
{ "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": false}]
|
|
|
|
convert -c -S 4k
|
|
[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 1024, "length": 7168, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 8192, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": false}]
|
|
|
|
convert -S 8k
|
|
[{ "start": 0, "length": 9216, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
{ "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
{ "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": false}]
|
|
|
|
convert -c -S 8k
|
|
[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 1024, "length": 7168, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 8192, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false},
|
|
{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true},
|
|
{ "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": false}]
|
|
*** done
|