qcow2: Implement bdrv_truncate() for growing images
commit419b19d9b427fad5ff2fa886d8cc217f7acee18c
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 28 Apr 2010 10:36:11 +0000 (28 11:36 +0100)
committerKevin Wolf <kwolf@redhat.com>
Mon, 3 May 2010 08:07:32 +0000 (3 10:07 +0200)
treea119877c837b2f6e053823001c111f12a3388c31
parent003fad6e2cae5311d3aea996388c90e3ab17de90
qcow2: Implement bdrv_truncate() for growing images

This patch adds the ability to grow qcow2 images in-place using
bdrv_truncate().  This enables qemu-img resize command support for
qcow2.

Snapshots are not supported and bdrv_truncate() will return -ENOTSUP.
The notion of resizing an image with snapshots could lead to confusion:
users may expect snapshots to remain unchanged, but this is not possible
with the current qcow2 on-disk format where the header.size field is
global instead of per-snapshot.  Others may expect snapshots to change
size along with the current image data.  I think it is safest to not
support snapshots and perhaps add behavior later if there is a
consensus.

Backing images continue to work.  If the image is now larger than its
backing image, zeroes are read when accessing beyond the end of the
backing image.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c
block/qcow2.h