qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v8 1/4] qemu-img: add --shrink flag for resize


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v8 1/4] qemu-img: add --shrink flag for resize
Date: Mon, 18 Sep 2017 20:12:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-09-18 14:42, Pavel Butsykin wrote:
> The flag is additional precaution against data loss. Perhaps in the future the
> operation shrink without this flag will be blocked for all formats, but for 
> now
> we need to maintain compatibility with raw.
> 
> Signed-off-by: Pavel Butsykin <address@hidden>
> Reviewed-by: Max Reitz <address@hidden>
> Reviewed-by: John Snow <address@hidden>
> ---
>  qemu-img-cmds.hx       |  4 ++--
>  qemu-img.c             | 23 +++++++++++++++++++++++
>  qemu-img.texi          |  6 +++++-
>  tests/qemu-iotests/102 |  4 ++--
>  tests/qemu-iotests/106 |  2 +-
>  5 files changed, 33 insertions(+), 6 deletions(-)

[...]

> diff --git a/qemu-img.c b/qemu-img.c
> index 56ef49e214..b7b2386cbd 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c

[...]

> @@ -3571,6 +3577,23 @@ static int img_resize(int argc, char **argv)
>          goto out;
>      }
>  
> +    if (total_size < current_size && !shrink) {
> +        warn_report("Shrinking an image will delete all data beyond the "
> +                    "shrunken image's end. Before performing such an "
> +                    "operation, make sure there is no important data 
> there.");
> +
> +        if (g_strcmp0(bdrv_get_format_name(blk_bs(blk)), "raw") != 0) {
> +            error_report(
> +              "Use the --shrink option to perform a shrink operation.");
> +            ret = -1;
> +            goto out;
> +        } else {
> +            warn_report("Using the --shrink option will suppress this 
> message."

Still missing a space here.

Max

> +                        "Note that future versions of qemu-img may refuse to 
> "
> +                        "shrink images without this option.");
> +        }
> +    }
> +
>      ret = blk_truncate(blk, total_size, prealloc, &err);
>      if (!ret) {
>          qprintf(quiet, "Image resized.\n");

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]