From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwh-0005KE-3J for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5gwc-0004sb-9Z for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:06 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:49602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwc-0004nV-2e for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:02 -0500 Received: by mail-gy0-f173.google.com with SMTP id r14so438364ghr.4 for ; Thu, 08 Mar 2012 09:16:01 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 8 Mar 2012 18:15:15 +0100 Message-Id: <1331226917-6658-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> References: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 15/17] raw: add get_info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Now that everything is in place we can declare discard support for the file protocol (and the raw format). Signed-off-by: Paolo Bonzini --- 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