On 2017-08-17 11:15, 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 <[email protected]> > Reviewed-by: Max Reitz <[email protected]> > --- > qemu-img-cmds.hx | 4 ++-- > qemu-img.c | 23 +++++++++++++++++++++++ > qemu-img.texi | 6 +++++- > tests/qemu-iotests/102 | 4 ++-- > 4 files changed, 32 insertions(+), 5 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."
Sorry, I only just noticed that there's a space missing after the period.
And I noticed because iotest 106 is failing, which will need to be fixed
just like 102.
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");
signature.asc
Description: OpenPGP digital signature
