On 2013年11月27日 10:15, Hu Tao wrote:
Signed-off-by: Hu Tao <hu...@cn.fujitsu.com>
---
block/qcow2.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index b054a01..a23fade 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2180,6 +2180,12 @@ static int qcow2_amend_options(BlockDriverState *bs,
return 0;
}
+static int qcow2_preallocate(BlockDriverState *bs, int64_t offset,
+ int64_t length)
+{
+ return bdrv_preallocate(bs->file, offset, length);
+}
+
What's the semantics of .bdrv_preallocate? I think you should map
[offset, offset + length) to clusters in image file, and then forward to
bs->file, rather than this direct wrapper.
E.g. bdrv_preallocate(qcow2_bs, 0, cluster_size) should call
bdrv_preallocate(qcow2_bs->file, offset_off_first_cluster, cluster_size).
Fam
static QEMUOptionParameter qcow2_create_options[] = {
{
.name = BLOCK_OPT_SIZE,
@@ -2234,6 +2240,7 @@ static BlockDriver bdrv_qcow2 = {
.bdrv_reopen_prepare = qcow2_reopen_prepare,
.bdrv_create = qcow2_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
+ .bdrv_preallocate = qcow2_preallocate,
.bdrv_co_get_block_status = qcow2_co_get_block_status,
.bdrv_set_key = qcow2_set_key,
.bdrv_make_empty = qcow2_make_empty,