From patchwork Thu Feb 7 16:15:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 218947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 055572C0082 for ; Fri, 8 Feb 2013 03:16:18 +1100 (EST) Received: from localhost ([::1]:38721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3U91-0007zF-G6 for incoming@patchwork.ozlabs.org; Thu, 07 Feb 2013 11:16:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3U8Q-0007jW-Ow for qemu-devel@nongnu.org; Thu, 07 Feb 2013 11:15:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U3U8E-0001LU-CW for qemu-devel@nongnu.org; Thu, 07 Feb 2013 11:15:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3U8E-0001LN-51 for qemu-devel@nongnu.org; Thu, 07 Feb 2013 11:15:26 -0500 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 r17GFPRh015185 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Feb 2013 11:15:25 -0500 Received: from localhost (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r17GFO8V011491; Thu, 7 Feb 2013 11:15:24 -0500 From: Stefan Hajnoczi To: Date: Thu, 7 Feb 2013 17:15:04 +0100 Message-Id: <1360253705-10400-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1360253705-10400-1-git-send-email-stefanha@redhat.com> References: <1360253705-10400-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , fsimonce@redhat.com, Stefan Hajnoczi , crobinso@redhat.com Subject: [Qemu-devel] [PATCH v3 4/5] qemu-img: add compressed clusters to BlockFragInfo 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 Show how many clusters are compressed. This can be used to monitor how many compressed clusters remain and whether to recompress the image. Suggested-by: Cole Robinson Signed-off-by: Stefan Hajnoczi --- include/block/block.h | 1 + qapi-schema.json | 6 +++++- qemu-img.c | 7 +++++-- tests/qemu-iotests/044.out | 1 + tests/qemu-iotests/common.rc | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index ce61883..9661f9a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -24,6 +24,7 @@ typedef struct BlockFragInfo { uint64_t allocated_clusters; uint64_t total_clusters; uint64_t fragmented_clusters; + uint64_t compressed_clusters; } BlockFragInfo; typedef struct QEMUSnapshotInfo { diff --git a/qapi-schema.json b/qapi-schema.json index 9831c87..65aea75 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -279,6 +279,10 @@ # field is present if the driver for the image format # supports it # +# @compressed-clusters: #optional total number of compressed clusters, this +# field is present if the driver for the image format +# supports it +# # Since: 1.4 # ## @@ -288,7 +292,7 @@ '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int', '*corruptions-fixed': 'int', '*leaks-fixed': 'int', '*total-clusters': 'int', '*allocated-clusters': 'int', - '*fragmented-clusters': 'int' } } + '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } } ## # @StatusInfo: diff --git a/qemu-img.c b/qemu-img.c index 0e34bf0..fa9b2af 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -428,10 +428,11 @@ static void dump_human_image_check(ImageCheck *check) if (check->total_clusters != 0 && check->allocated_clusters != 0) { printf("%" PRId64 "/%" PRId64 " = %0.2f%% allocated, " - "%0.2f%% fragmented\n", + "%0.2f%% fragmented, %0.2f%% compressed clusters\n", check->allocated_clusters, check->total_clusters, check->allocated_clusters * 100.0 / check->total_clusters, - check->fragmented_clusters * 100.0 / check->allocated_clusters); + check->fragmented_clusters * 100.0 / check->allocated_clusters, + check->compressed_clusters * 100.0 / check->allocated_clusters); } if (check->image_end_offset) { @@ -472,6 +473,8 @@ static int collect_image_check(BlockDriverState *bs, check->has_allocated_clusters = result.bfi.allocated_clusters != 0; check->fragmented_clusters = result.bfi.fragmented_clusters; check->has_fragmented_clusters = result.bfi.fragmented_clusters != 0; + check->compressed_clusters = result.bfi.compressed_clusters; + check->has_compressed_clusters = result.bfi.compressed_clusters != 0; return 0; } diff --git a/tests/qemu-iotests/044.out b/tests/qemu-iotests/044.out index 9c48673..5eed3f8 100644 --- a/tests/qemu-iotests/044.out +++ b/tests/qemu-iotests/044.out @@ -1,4 +1,5 @@ No errors were found on the image. +7292415/8391499= 86.90% allocated, 0.00% fragmented, 0.00% compressed clusters Image end offset: 4296447488 . ---------------------------------------------------------------------- diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 5ba960b..e522d61 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -162,7 +162,7 @@ _cleanup_test_img() _check_test_img() { $QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \ - sed -e "/fragmented$/d" \ + sed -e '/allocated.*fragmented.*compressed clusters/d' \ -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \ -e '/Image end offset: [0-9]\+/d' }