From nobody Sun Oct 5 21:12:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15477397143878.700265532584467; Thu, 17 Jan 2019 07:41:54 -0800 (PST) Received: from localhost ([127.0.0.1]:46798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9nf-0007TN-TU for importer@patchew.org; Thu, 17 Jan 2019 10:41:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9fu-00017j-Ff for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk9ft-0005Un-Az for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:33:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gk9fn-0004sX-Ik; Thu, 17 Jan 2019 10:33:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48826C0C7CB8; Thu, 17 Jan 2019 15:33:27 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FA765C729; Thu, 17 Jan 2019 15:33:26 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 09:33:20 -0600 Message-Id: <20190117153321.29749-3-eblake@redhat.com> In-Reply-To: <20190117153321.29749-1-eblake@redhat.com> References: <20190117153321.29749-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 17 Jan 2019 15:33:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] file: Expose some protocol-specific information X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, "open list:raw" , Markus Armbruster , Max Reitz , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When analyzing performance, it might be nice to let 'qemu-img info' expose details that it learned from the underlying file or block device. Start the process by picking a few useful items determined during raw_open_common(). Signed-off-by: Eric Blake --- qapi/block-core.json | 24 +++++++++++++++++++++++- block/file-posix.c | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index f28d5f5fc76..296c22a1003 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -101,6 +101,25 @@ 'extents': ['ImageInfo'] } } +## +# @ImageInfoSpecificFile: +# +# Details about a file protocol BDS. +# +# @align: Alignment in use +# +# @discard: True if discard operations can be attempted +# +# @write-zero: True if efficient write zero operations can be attempted +# +# @discard-zero: True if discarding is known to read back as zero +# +# Since: 4.0 +## +{ 'struct': 'ImageInfoSpecificFile', + 'data': { 'align': 'int', 'discard': 'bool', 'write-zero': 'bool', + '*discard-zero': 'bool' } } + ## # @ImageInfoSpecific: # @@ -110,12 +129,15 @@ ## { 'union': 'ImageInfoSpecific', 'data': { + # Format drivers: 'qcow2': 'ImageInfoSpecificQCow2', 'vmdk': 'ImageInfoSpecificVmdk', # If we need to add block driver specific parameters for # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS # to define a ImageInfoSpecificLUKS - 'luks': 'QCryptoBlockInfoLUKS' + 'luks': 'QCryptoBlockInfoLUKS', + # Protocol drivers: + 'file': 'ImageInfoSpecificFile' } } ## diff --git a/block/file-posix.c b/block/file-posix.c index 8aee7a3fb8b..d4ce0e9116c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1079,6 +1079,23 @@ static void raw_refresh_limits(BlockDriverState *bs,= Error **errp) bs->bl.opt_mem_alignment =3D MAX(s->buf_align, getpagesize()); } +static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + ImageInfoSpecific *info =3D g_new0(ImageInfoSpecific, 1); + ImageInfoSpecificFile *infofile =3D g_new0(ImageInfoSpecificFile, 1); + + info->type =3D IMAGE_INFO_SPECIFIC_KIND_FILE; + info->u.file.data =3D infofile; + infofile->align =3D s->buf_align; + infofile->discard =3D s->has_discard; + infofile->write_zero =3D s->has_write_zeroes; + infofile->has_discard_zero =3D s->has_discard; + infofile->discard_zero =3D s->discard_zeroes; + + return info; +} + static int check_for_dasd(int fd) { #ifdef BIODASDINFO2 @@ -2765,6 +2782,7 @@ BlockDriver bdrv_file =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3240,6 +3258,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_co_copy_range_from =3D raw_co_copy_range_from, .bdrv_co_copy_range_to =3D raw_co_copy_range_to, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3363,6 +3382,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, @@ -3494,6 +3514,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_co_pwritev =3D raw_co_pwritev, .bdrv_co_flush_to_disk =3D raw_co_flush_to_disk, .bdrv_refresh_limits =3D raw_refresh_limits, + .bdrv_get_specific_info =3D raw_get_specific_info, .bdrv_io_plug =3D raw_aio_plug, .bdrv_io_unplug =3D raw_aio_unplug, .bdrv_attach_aio_context =3D raw_aio_attach_aio_context, --=20 2.20.1