diff mbox

[RFC,v3,5/6] qcow2: implement bdrv_preallocate

Message ID dbd15f28b4544f56edb37cc9bbb4dacfc5feae56.1387419339.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao Dec. 19, 2013, 2:27 a.m. UTC
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 block/qcow2.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefan Hajnoczi Dec. 20, 2013, 10:19 a.m. UTC | #1
On Thu, Dec 19, 2013 at 10:27:40AM +0800, Hu Tao wrote:
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  block/qcow2.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 32cb39f..487a595 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2188,6 +2188,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 about qcow2-level preallocation (metadata)?

I'm not sure what the meaning of offset and length are here - are they
supposed to be virtual disk LBAs.  They are being passed through to
bs->file so they actually become physical file offsets.
diff mbox

Patch

diff --git a/block/qcow2.c b/block/qcow2.c
index 32cb39f..487a595 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2188,6 +2188,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);
+}
+
 static QEMUOptionParameter qcow2_create_options[] = {
     {
         .name = BLOCK_OPT_SIZE,
@@ -2242,6 +2248,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,