]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-img: add compressed clusters to BlockFragInfo
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 7 Feb 2013 16:15:04 +0000 (17:15 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 Feb 2013 20:21:09 +0000 (21:21 +0100)
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 <crobinso@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
include/block/block.h
qapi-schema.json
qemu-img.c
tests/qemu-iotests/044.out
tests/qemu-iotests/common.rc

index ce61883fc9955773fb1c851f8f15fecb35087dd2..9661f9aa467aa50943357c4adae78008950b8bdd 100644 (file)
@@ -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 {
index c20725c7f7c379694388b7afcf90fe56f60f883d..28b070f16bb560d0f64203dc0900e4bb406e516c 100644 (file)
 #                       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
 #
 ##
            '*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:
index 0e34bf0c90bc5ddb1707d300296c04e99fd98340..fa9b2af79d1bcb312ec3adf312c8e5d114d13dd1 100644 (file)
@@ -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;
 }
index 9c4867329f8a97ae36dea5531cd43298a800ebaf..5eed3f87a324352bce82eb8d4f843c929409fe1c 100644 (file)
@@ -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
 .
 ----------------------------------------------------------------------
index 5ba960b09fdabaf02bb01b64a031725a1669c872..e522d617aa20782a35f1616756c6a4997be3a4a2 100644 (file)
@@ -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'
 }