block: add apparent-size to query-block
PATCH 1/1 block: add apparent-size to query-block
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.
--- block/qapi.c | 3 ++- qapi-schema.json | 4 +++- qmp-commands.hx | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
block/qapi.c +2 -1
@@ -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;
qapi-schema.json +3 -1
@@ -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'],
qmp-commands.hx +1 -0
@@ -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
Signature · 1 line
1.7.1
Quoted 15 lines · Federico Simoncelli
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 <[email protected]>--- block/qapi.c | 3 ++- qapi-schema.json | 4 +++- qmp-commands.hx | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)+++
b/qapi-schema.json
qapi-schema.json line 225
Quoted 4 lines
qapi-schema.json +1
-0@@ -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
Worth adding a '(since 1.6)' notation. Is there any more documentation you can list here to differentiate between the different sizes?
qapi-schema.json line 249
Quoted 10 lines
qapi-schema.json +2
-1+# # @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',
Long line; may be worth wrapping. Is this parameter always present, even if it is identical to 'actual-size' for some file formats, or should it be marked optional?
qemu-img should be enhanced to output the new information.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 21.06.2013 um 18:18 hat Federico Simoncelli geschrieben:
Quoted 6 lines
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 <[email protected]>
Instead of pulling one specific field up from bs->file and giving it a non-obvious name, we should rather add something generally useful like a field '*file': 'ImageInfo' that works as an analog to *backing-image, just that it contains the info for bs->file instead of bs->backing_hd.
Kevin