From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq43h-0005NE-Nl for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq43f-00071c-Ug for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:19:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq43f-00071P-NW for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:19:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5LGJUqf009007 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Jun 2013 12:19:30 -0400 From: Federico Simoncelli Date: Fri, 21 Jun 2013 12:18:48 -0400 Message-Id: <1371831528-1128-1-git-send-email-fsimonce@redhat.com> Subject: [Qemu-devel] [PATCH] block: add apparent-size to query-block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, 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 --- 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