mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 02:54:58 -06:00
qcow2: Make preallocate_co() resize the image to the correct size
This function preallocates metadata structures and then extends the image to its new size, but that new size calculation is wrong because it doesn't take into account that the host_offset variable is always cluster-aligned. This problem can be reproduced with preallocation=metadata when the original size is not cluster-aligned but the new size is. In this case the final image size will be shorter than expected. qemu-img create -f qcow2 img.qcow2 31k qemu-img resize --preallocation=metadata img.qcow2 128k Signed-off-by: Alberto Garcia <berto@igalia.com> Message-Id: <adeb8b059917b141d5f5b3bd2a016262d3052c79.1599833007.git.berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> [mreitz: Mark compat=0.10 unsupported for iotest 125] Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
c1dadda02c
commit
8e958260c5
3 changed files with 53 additions and 20 deletions
|
@ -768,11 +768,35 @@ wrote 81920/81920 bytes at offset 2048000
|
|||
80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=131072
|
||||
--- Resizing image from 31k to 96k ---
|
||||
--- Resizing image from 31k to 96k (preallocation=metadata) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=31744 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 33k to 96k ---
|
||||
--- Resizing image from 31k to 96k (preallocation=full) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=31744 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 31k to 128k (preallocation=metadata) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=31744 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 31k to 128k (preallocation=full) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=31744 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 33k to 96k (preallocation=metadata) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33792 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 33k to 96k (preallocation=full) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33792 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 33k to 128k (preallocation=metadata) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33792 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
--- Resizing image from 33k to 128k (preallocation=full) ---
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33792 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
|
||||
Image resized.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue