[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qemu-img: refuse to compress files with invalid
From: |
Benoît Canet |
Subject: |
Re: [Qemu-devel] [PATCH] qemu-img: refuse to compress files with invalid size |
Date: |
Fri, 12 Apr 2013 21:55:14 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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 <address@hidden>
> ---
> 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 <address@hidden>