Blob Blame History Raw
From 6c316a417a80fcf892935c51eb01c0e273561b32 Mon Sep 17 00:00:00 2001
From: Max Reitz <mreitz@redhat.com>
Date: Mon, 13 Mar 2017 17:47:04 +0100
Subject: [PATCH 16/24] blkdebug: Add bdrv_truncate()

RH-Author: Max Reitz <mreitz@redhat.com>
Message-id: <20170313174706.29316-1-mreitz@redhat.com>
Patchwork-id: 74278
O-Subject: [RHEL-7.4 qemu-kvm PATCH 7/9] blkdebug: Add bdrv_truncate()
Bugzilla: 1427176
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

From: Kevin Wolf <kwolf@redhat.com>

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>
Reviewed-by: Jeff Cody <jcody@redhat.com>
(cherry picked from commit 8eedfbd4a50299f03b3630659c34ad1b01f69370)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>

Conflicts:
	block/blkdebug.c

Contextual conflict due to blkdebug_refresh_filename() missing from
downstream.

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

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 8e468b2..7cfeccb 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -652,6 +652,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 BlockDriver bdrv_blkdebug = {
     .format_name            = "blkdebug",
     .protocol_name          = "blkdebug",
@@ -661,6 +666,7 @@ static BlockDriver bdrv_blkdebug = {
     .bdrv_file_open         = blkdebug_open,
     .bdrv_close             = blkdebug_close,
     .bdrv_getlength         = blkdebug_getlength,
+    .bdrv_truncate          = blkdebug_truncate,
 
     .bdrv_aio_readv         = blkdebug_aio_readv,
     .bdrv_aio_writev        = blkdebug_aio_writev,
-- 
1.8.3.1