From 6c316a417a80fcf892935c51eb01c0e273561b32 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 13 Mar 2017 17:47:04 +0100 Subject: [PATCH 16/24] blkdebug: Add bdrv_truncate() RH-Author: Max Reitz 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 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Kevin Wolf From: Kevin Wolf 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 Reviewed-by: Jeff Cody (cherry picked from commit 8eedfbd4a50299f03b3630659c34ad1b01f69370) Signed-off-by: Miroslav Rezanina Conflicts: block/blkdebug.c Contextual conflict due to blkdebug_refresh_filename() missing from downstream. Signed-off-by: Max Reitz --- 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