qed: support for growing images
PATCH 1/1 qed: support for growing images
The .bdrv_truncate() operation resizes images and growing is easy to implement in QED. Simply check that the new size is valid and then update the image_size header field to reflect the new size.
Signed-off-by Stefan Hajnoczi <[email protected]>
--- block/qed.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-)
block/qed.c +21 -1
@@ -1233,7 +1233,27 @@ static BlockDriverAIOCB *bdrv_qed_aio_flush(BlockDriverState *bs,static int bdrv_qed_truncate (BlockDriverState *bs,int64_t offset) { -return -ENOTSUP ; +BDRVQEDState *s = bs->opaque; +uint64_t old_image_size; +int ret; + +if (!qed_is_image_size_valid (offset, s->header.cluster_size, + s->header.table_size)) { +return -EINVAL ; + } + +/* Shrinking is currently not supported */ +if ((uint64_t )offset < s->header.image_size) { +return -ENOTSUP ; + } + + old_image_size = s->header.image_size; + s->header.image_size = offset; + ret =qed_write_header_sync (s); +if (ret <0 ) { + s->header.image_size = old_image_size; + } +return ret; }static int64_t bdrv_qed_getlength (BlockDriverState *bs)
Signature · 1 line
1.7.4.4
Kevin Wolf
AppliedAm 16.05.2011 14:56, schrieb Stefan Hajnoczi:
Quoted 5 lines
The .bdrv_truncate() operation resizes images and growing is easy to implement in QED. Simply check that the new size is valid and then update the
image_sizeheader field to reflect the new size.Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks, applied to the block branch.
Kevin