qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Federico Simoncelli <fsimonce@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Federico Simoncelli <fsimonce@redhat.com>
Subject: [Qemu-devel] [PATCH] block: add apparent-size to query-block
Date: Fri, 21 Jun 2013 12:18:48 -0400	[thread overview]
Message-ID: <1371831528-1128-1-git-send-email-fsimonce@redhat.com> (raw)

This patch adds the apparent-size entry to the query-block output.
The value represents the apparent size in bytes of the image, e.g.
file size (including the blocks not yet allocated) or block device
size.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
 block/qapi.c     |    3 ++-
 qapi-schema.json |    4 +++-
 qmp-commands.hx  |    1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index a4bc411..ccaba67 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -119,8 +119,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
 
     info->filename        = g_strdup(bs->filename);
     info->format          = g_strdup(bdrv_get_format_name(bs));
-    info->virtual_size    = total_sectors * 512;
+    info->virtual_size    = bdrv_getlength(bs);
     info->actual_size     = bdrv_get_allocated_file_size(bs);
+    info->apparent_size   = bdrv_getlength(bs->file);
     info->has_actual_size = info->actual_size >= 0;
     if (bdrv_is_encrypted(bs)) {
         info->encrypted = true;
diff --git a/qapi-schema.json b/qapi-schema.json
index a80ee40..c7403ed 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -222,6 +222,8 @@
 #
 # @actual-size: #optional actual size on disk in bytes of the image
 #
+# @apparent-size: apparent size in bytes of the image
+#
 # @dirty-flag: #optional true if image is not cleanly closed
 #
 # @cluster-size: #optional size of a cluster in bytes
@@ -244,7 +246,7 @@
 
 { 'type': 'ImageInfo',
   'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
-           '*actual-size': 'int', 'virtual-size': 'int',
+           '*actual-size': 'int', 'virtual-size': 'int', 'apparent-size': 'int',
            '*cluster-size': 'int', '*encrypted': 'bool',
            '*backing-filename': 'str', '*full-backing-filename': 'str',
            '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8cea5e5..3f3aded 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1714,6 +1714,7 @@ Each json-object contain the following:
              - "actual-size": actual size on disk in bytes of the image, not
                               present when image does not support thin
                               provision (json-int, optional)
+             - "apparent-size": apparent size in bytes of the image
              - "cluster-size": size of a cluster in bytes, not present if image
                                format does not support it (json-int, optional)
              - "encrypted": true if the image is encrypted, not present means
-- 
1.7.1

             reply	other threads:[~2013-06-21 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 16:18 Federico Simoncelli [this message]
2013-06-21 20:06 ` [Qemu-devel] [PATCH] block: add apparent-size to query-block Eric Blake
2013-06-24 12:22 ` Kevin Wolf

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=1371831528-1128-1-git-send-email-fsimonce@redhat.com \
    --to=fsimonce@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).