qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com,
	Max Reitz <mreitz@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"open list:raw" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH 2/3] file: Expose some protocol-specific information
Date: Thu, 17 Jan 2019 09:33:20 -0600	[thread overview]
Message-ID: <20190117153321.29749-3-eblake@redhat.com> (raw)
In-Reply-To: <20190117153321.29749-1-eblake@redhat.com>

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 <eblake@redhat.com>
---
 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 = MAX(s->buf_align, getpagesize());
 }

+static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs)
+{
+    BDRVRawState *s = bs->opaque;
+    ImageInfoSpecific *info = g_new0(ImageInfoSpecific, 1);
+    ImageInfoSpecificFile *infofile = g_new0(ImageInfoSpecificFile, 1);
+
+    info->type = IMAGE_INFO_SPECIFIC_KIND_FILE;
+    info->u.file.data = infofile;
+    infofile->align = s->buf_align;
+    infofile->discard = s->has_discard;
+    infofile->write_zero = s->has_write_zeroes;
+    infofile->has_discard_zero = s->has_discard;
+    infofile->discard_zero = s->discard_zeroes;
+
+    return info;
+}
+
 static int check_for_dasd(int fd)
 {
 #ifdef BIODASDINFO2
@@ -2765,6 +2782,7 @@ BlockDriver bdrv_file = {
     .bdrv_co_copy_range_from = raw_co_copy_range_from,
     .bdrv_co_copy_range_to  = raw_co_copy_range_to,
     .bdrv_refresh_limits = raw_refresh_limits,
+    .bdrv_get_specific_info = raw_get_specific_info,
     .bdrv_io_plug = raw_aio_plug,
     .bdrv_io_unplug = raw_aio_unplug,
     .bdrv_attach_aio_context = raw_aio_attach_aio_context,
@@ -3240,6 +3258,7 @@ static BlockDriver bdrv_host_device = {
     .bdrv_co_copy_range_from = raw_co_copy_range_from,
     .bdrv_co_copy_range_to  = raw_co_copy_range_to,
     .bdrv_refresh_limits = raw_refresh_limits,
+    .bdrv_get_specific_info = raw_get_specific_info,
     .bdrv_io_plug = raw_aio_plug,
     .bdrv_io_unplug = raw_aio_unplug,
     .bdrv_attach_aio_context = raw_aio_attach_aio_context,
@@ -3363,6 +3382,7 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_co_pwritev        = raw_co_pwritev,
     .bdrv_co_flush_to_disk  = raw_co_flush_to_disk,
     .bdrv_refresh_limits = raw_refresh_limits,
+    .bdrv_get_specific_info = raw_get_specific_info,
     .bdrv_io_plug = raw_aio_plug,
     .bdrv_io_unplug = raw_aio_unplug,
     .bdrv_attach_aio_context = raw_aio_attach_aio_context,
@@ -3494,6 +3514,7 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_co_pwritev        = raw_co_pwritev,
     .bdrv_co_flush_to_disk  = raw_co_flush_to_disk,
     .bdrv_refresh_limits = raw_refresh_limits,
+    .bdrv_get_specific_info = raw_get_specific_info,
     .bdrv_io_plug = raw_aio_plug,
     .bdrv_io_unplug = raw_aio_unplug,
     .bdrv_attach_aio_context = raw_aio_attach_aio_context,
-- 
2.20.1

  parent reply	other threads:[~2019-01-17 15:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 15:33 [Qemu-devel] [RFC PATCH 0/3] Expand 'qemu-img info' to show protocol details Eric Blake
2019-01-17 15:33 ` [Qemu-devel] [PATCH 1/3] block: Expose protocol-specific data to 'qemu-img info' Eric Blake
2019-01-17 16:39   ` Kevin Wolf
2019-01-17 17:46     ` Eric Blake
2019-01-18 14:20   ` Vladimir Sementsov-Ogievskiy
2019-01-17 15:33 ` Eric Blake [this message]
2019-01-18 14:08   ` [Qemu-devel] [PATCH 2/3] file: Expose some protocol-specific information Vladimir Sementsov-Ogievskiy
2019-01-18 16:15     ` Eric Blake
2019-01-17 15:33 ` [Qemu-devel] [PATCH 3/3] RFC: nbd: Expose " Eric Blake
2019-01-17 16:06 ` [Qemu-devel] [RFC PATCH 0/3] Expand 'qemu-img info' to show protocol details Daniel P. Berrangé
2019-01-17 16:15   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190117153321.29749-3-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).