On 6/10/20 4:46 AM, Alberto Garcia wrote:
When resizing an image with qcow2_co_truncate() using the falloc or
full preallocation modes the code assumes that both the old and new
sizes are cluster-aligned.

There are two problems with this:

   1) The calculation of how many clusters are involved does not always
      get the right result.

      Example: creating a 60KB image and resizing it (with
      preallocation=full) to 80KB won't allocate the second cluster.

   2) No copy-on-write is performed, so in the previous example if
      there is a backing file then the first 60KB of the first cluster
      won't be filled with data from the backing file.

This patch fixes both issues.

Signed-off-by: Alberto Garcia <[email protected]>
---
  block/qcow2.c              | 17 ++++++++++++++---
  tests/qemu-iotests/125     | 21 +++++++++++++++++++++
  tests/qemu-iotests/125.out |  9 +++++++++
  3 files changed, 44 insertions(+), 3 deletions(-)


Reviewed-by: Eric Blake <[email protected]>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Reply via email to