[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/5] qemu-img: add compressed clusters to BlockFragI
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 4/5] qemu-img: add compressed clusters to BlockFragInfo |
Date: |
Tue, 5 Feb 2013 19:54:10 +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 <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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(-)
diff --git a/include/block/block.h b/include/block/block.h
index 5c3b911..24db852 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/qemu-img.c b/qemu-img.c
index 167d65f..a06456b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -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\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);
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index 1602ccd..32c6d32 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -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
diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036
index 329533e..3c76d89 100755
--- a/tests/qemu-iotests/036
+++ b/tests/qemu-iotests/036
@@ -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
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index c5ae806..ae35175 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -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
diff --git a/tests/qemu-iotests/044.out b/tests/qemu-iotests/044.out
index 7a40071..875df0c 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
.
----------------------------------------------------------------------
Ran 1 tests
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index aef5f52..1c09e73 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -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 | \
+ grep -v -e "compressed$" | \
+ sed -e 's/qemu-img\: This image format does not support checks/No
errors were found on the image./'
}
_img_info()
--
1.8.1