Le Friday 12 Apr 2013 à 19:37:48 (+0200), Stefan Hajnoczi a écrit :
> Image file compression works at cluster granularity. It is not possible
> to compress less than a cluster of data at a time.
>
> Print an error when attempting qemu-img convert -c with an input file
> that is not a multiple of the cluster size.
>
> I considered automatically adjusting the output file size but think it's
> better to be explicit. This avoids confusion when users notice that
> image file size changed after conversion.
>
> Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
> ---
> qemu-img.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 31627b0..2273851 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1370,6 +1370,13 @@ static int img_convert(int argc, char **argv)
> goto out;
> }
> cluster_sectors = cluster_size >> 9;
> + if (total_sectors % cluster_sectors) {
> + error_report("compression requires that input file size is a "
> + "multiple of %d bytes",
> + cluster_size);
> + ret = -1;
> + goto out;
> + }
> sector_num = 0;
>
> nb_sectors = total_sectors;
> --
> 1.8.1.4
>
>
Reviewed-by: Benoit Canet <ben...@irqsave.net>