Now that everything is in place we can declare discard support for the file protocol (and the raw format).
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- block/raw-posix.c | 9 +++++++++ block/raw.c | 6 ++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index f23d92b..56aabc7 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -635,6 +635,14 @@ static coroutine_fn int raw_co_discard(BlockDriverState *bs, #endif } +static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + bdi->cluster_size = BDRV_SECTOR_SIZE; + bdi->discard_zeroes_data = true; + bdi->discard_granularity = 1; + return 0; +} + static QEMUOptionParameter raw_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -660,6 +668,7 @@ static BlockDriver bdrv_file = { .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, + .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, diff --git a/block/raw.c b/block/raw.c index 1cdac0c..3618c2d 100644 --- a/block/raw.c +++ b/block/raw.c @@ -35,6 +35,11 @@ static int64_t raw_getlength(BlockDriverState *bs) return bdrv_getlength(bs->file); } +static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + return bdrv_get_info(bs->file, bdi); +} + static int raw_truncate(BlockDriverState *bs, int64_t offset) { return bdrv_truncate(bs->file, offset); @@ -118,6 +123,7 @@ static BlockDriver bdrv_raw = { .bdrv_probe = raw_probe, .bdrv_getlength = raw_getlength, + .bdrv_get_info = raw_get_info, .bdrv_truncate = raw_truncate, .bdrv_is_inserted = raw_is_inserted, -- 1.7.7.6