From patchwork Fri Jul 5 14:28:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Simoncelli X-Patchwork-Id: 257180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D3962C0099 for ; Sat, 6 Jul 2013 00:39:36 +1000 (EST) Received: from localhost ([::1]:34212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv7Ab-0001JT-MQ for incoming@patchwork.ozlabs.org; Fri, 05 Jul 2013 10:39:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv7AN-0001Hi-AW for qemu-devel@nongnu.org; Fri, 05 Jul 2013 10:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uv7AM-0006Uz-8e for qemu-devel@nongnu.org; Fri, 05 Jul 2013 10:39:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv70V-0002T0-1P for qemu-devel@nongnu.org; Fri, 05 Jul 2013 10:29:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r65ET441027414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Jul 2013 10:29:04 -0400 Received: from vm-rhdev1.in1.bytenix.com (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r65ET2Bx002072; Fri, 5 Jul 2013 10:29:03 -0400 From: Federico Simoncelli To: qemu-devel@nongnu.org Date: Fri, 5 Jul 2013 10:28:52 -0400 Message-Id: <1373034532-21765-1-git-send-email-fsimonce@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@gmail.com, Federico Simoncelli Subject: [Qemu-devel] [PATCHv2] block: add the optional file entry to query-block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds the optional file entry to the query-block output. The value is a json-object representing the information about the underlying file or device (when present). Signed-off-by: Federico Simoncelli Reviewed-by: Eric Blake --- block/qapi.c | 7 +++++++ qapi-schema.json | 4 +++- qmp-commands.hx | 8 ++++++++ tests/qemu-iotests/043.out | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 1 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index a4bc411..40db983 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -171,6 +171,13 @@ void bdrv_query_image_info(BlockDriverState *bs, return; } + if (bs->file) { + bdrv_query_image_info(bs->file, &info->file, &err); + if (info->file) { + info->has_file = true; + } + } + *p_info = info; } diff --git a/qapi-schema.json b/qapi-schema.json index 5c32528..0cb872c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -238,6 +238,8 @@ # # @backing-image: #optional info of the backing image (since 1.6) # +# @file: #optional info of the underlying file (since 1.6) +# # Since: 1.3 # ## @@ -248,7 +250,7 @@ '*cluster-size': 'int', '*encrypted': 'bool', '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'], - '*backing-image': 'ImageInfo' } } + '*backing-image': 'ImageInfo', '*file': 'ImageInfo' } } ## # @ImageCheck: diff --git a/qmp-commands.hx b/qmp-commands.hx index 362f0e1..bb8a931 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1791,6 +1791,8 @@ Each json-object contain the following: - "backing-image": the detail of the backing image, it is an optional json-object only present when a backing image present for this image + - "file": an optional json-object representing the information + about the underlying file or device (when present) - "io-status": I/O operation status, only present if the device supports it and the VM is configured to stop on errors. It's always reset @@ -1842,6 +1844,12 @@ Example: "format":"qcow2", "virtual-size":2048000 } + "file":{ + "filename":"disks/test.qcow2", + "format": "file", + "virtual-size": 262144, + "actual-size": 139264 + } } }, "type":"unknown" diff --git a/tests/qemu-iotests/043.out b/tests/qemu-iotests/043.out index ad23337..6aea37b 100644 --- a/tests/qemu-iotests/043.out +++ b/tests/qemu-iotests/043.out @@ -44,6 +44,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT", + "format": "file", + }, "backing-filename": "TEST_DIR/t.IMGFMT.2.base", "dirty-flag": false }, @@ -52,6 +57,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT.2.base", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT.2.base", + "format": "file", + }, "backing-filename": "TEST_DIR/t.IMGFMT.1.base", "dirty-flag": false }, @@ -60,6 +70,11 @@ cluster_size: 65536 "filename": "TEST_DIR/t.IMGFMT.1.base", "cluster-size": 65536, "format": "IMGFMT", + "file": { + "virtual-size": 327680, + "filename": "TEST_DIR/t.IMGFMT.1.base", + "format": "file", + }, "dirty-flag": false } ]