[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] block: add apparent-size to query-block
From: |
Federico Simoncelli |
Subject: |
[Qemu-devel] [PATCH] block: add apparent-size to query-block |
Date: |
Fri, 21 Jun 2013 12:18:48 -0400 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH] block: add apparent-size to query-block,
Federico Simoncelli <=