Am 05.02.2013 19:54, schrieb Stefan Hajnoczi: > 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 <crobi...@redhat.com> > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
> 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); > } Having the output in this if block assumes that all block drivers either have both fragmentation and compression statistics or neither. Wouldn't it make more sense to check compressed_clusters separately and not print anything on non-qcow2 (and possibly even uncompressed qcow2) images? Instead of getting a longer and longer output line for each new number we add, maybe we could use the chance to introduce multiline output: Total number of clusters: 1000 - allocated 427 (42.7%) - fragmented 71 (7.1%) - compressed 120 (12.0%) Or something like that. And if a line doesn't apply to the given image (format), it's just left out. Kevin