@@ -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 {
@@ -471,10 +471,11 @@ static int img_check(int argc, char **argv)
if (bfi->total_clusters != 0 && bfi->allocated_clusters != 0) {
printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, "
- "%0.2f%% fragmented\n",
+ "%0.2f%% fragmented, %0.2f%% compressed clusters\n",
bfi->allocated_clusters, bfi->total_clusters,
bfi->allocated_clusters * 100.0 / bfi->total_clusters,
- bfi->fragmented_clusters * 100.0 / bfi->allocated_clusters);
+ bfi->fragmented_clusters * 100.0 / bfi->allocated_clusters,
+ bfi->compressed_clusters * 100.0 / bfi->allocated_clusters);
}
bdrv_delete(bs);
@@ -102,7 +102,7 @@ if [ "$event" == "l2_load" ]; then
$QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
fi
-$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img | grep -v "refcount=1 reference=0"
done
done
@@ -147,7 +147,7 @@ echo
echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
$QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io
-$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img | grep -v "refcount=1 reference=0"
done
done
@@ -186,7 +186,7 @@ echo
echo "Event: $event; errno: $errno; imm: $imm; once: $once"
$QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io
-$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img | grep -v "refcount=1 reference=0"
done
done
@@ -59,7 +59,7 @@ _make_test_img 64M
echo
echo === Repair image ===
echo
-$QEMU_IMG check -r all $TEST_IMG
+_check_test_img -r all
./qcow2.py $TEST_IMG dump-header
# success, all done
@@ -86,7 +86,7 @@ $QEMU_IO -r -c "read -P 0x5a 0 512" $TEST_IMG | _filter_qemu_io
echo
echo "== Repairing the image file must succeed =="
-$QEMU_IMG check -r all $TEST_IMG
+_check_test_img -r all
# The dirty bit must not be set
./qcow2.py $TEST_IMG dump-header | grep incompatible_features
@@ -1,4 +1,5 @@
No errors were found on the image.
+7292415/8391499= 86.90% allocated, 0.00% fragmented, 0.00% compressed clusters
.
----------------------------------------------------------------------
Ran 1 tests
@@ -161,9 +161,9 @@ _cleanup_test_img()
_check_test_img()
{
- $QEMU_IMG check -f $IMGFMT $TEST_IMG 2>&1 | \
- grep -v "fragmented$" | \
- sed -e 's/qemu-img\: This image format does not support checks/No errors were found on the image./'
+ $QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \
+ 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./'
}
_img_info()
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 | 1 + qemu-img.c | 5 +++-- tests/qemu-iotests/026 | 6 +++--- tests/qemu-iotests/036 | 2 +- tests/qemu-iotests/039 | 2 +- tests/qemu-iotests/044.out | 1 + tests/qemu-iotests/common.rc | 6 +++--- 7 files changed, 13 insertions(+), 10 deletions(-)