diff mbox

[1/2] blkdebug: Add bdrv_truncate()

Message ID 1429090046-6359-2-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf April 15, 2015, 9:27 a.m. UTC
This is, amongst others, required for qemu-iotests 033 to run as
intended on VHDX, which uses explicit bdrv_truncate() calls to bs->file
when allocating new blocks.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/blkdebug.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jeff Cody April 15, 2015, 11:35 a.m. UTC | #1
On Wed, Apr 15, 2015 at 11:27:25AM +0200, Kevin Wolf wrote:
> This is, amongst others, required for qemu-iotests 033 to run as
> intended on VHDX, which uses explicit bdrv_truncate() calls to bs->file
> when allocating new blocks.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/blkdebug.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/block/blkdebug.c b/block/blkdebug.c
> index 63611e0..3c30edb 100644
> --- a/block/blkdebug.c
> +++ b/block/blkdebug.c
> @@ -721,6 +721,11 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
>      return bdrv_getlength(bs->file);
>  }
>  
> +static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
> +{
> +    return bdrv_truncate(bs->file, offset);
> +}
> +
>  static void blkdebug_refresh_filename(BlockDriverState *bs)
>  {
>      QDict *opts;
> @@ -779,6 +784,7 @@ static BlockDriver bdrv_blkdebug = {
>      .bdrv_file_open         = blkdebug_open,
>      .bdrv_close             = blkdebug_close,
>      .bdrv_getlength         = blkdebug_getlength,
> +    .bdrv_truncate          = blkdebug_truncate,
>      .bdrv_refresh_filename  = blkdebug_refresh_filename,
>  
>      .bdrv_aio_readv         = blkdebug_aio_readv,
> -- 
> 1.8.3.1
>

Reviewed-by: Jeff Cody <jcody@redhat.com>
diff mbox

Patch

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 63611e0..3c30edb 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -721,6 +721,11 @@  static int64_t blkdebug_getlength(BlockDriverState *bs)
     return bdrv_getlength(bs->file);
 }
 
+static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
+{
+    return bdrv_truncate(bs->file, offset);
+}
+
 static void blkdebug_refresh_filename(BlockDriverState *bs)
 {
     QDict *opts;
@@ -779,6 +784,7 @@  static BlockDriver bdrv_blkdebug = {
     .bdrv_file_open         = blkdebug_open,
     .bdrv_close             = blkdebug_close,
     .bdrv_getlength         = blkdebug_getlength,
+    .bdrv_truncate          = blkdebug_truncate,
     .bdrv_refresh_filename  = blkdebug_refresh_filename,
 
     .bdrv_aio_readv         = blkdebug_aio_readv,