[{"id":1770385,"web_url":"http://patchwork.ozlabs.org/comment/1770385/","msgid":"<79cf9910-e76e-7c6d-f7c8-a81d84db0dd0@redhat.com>","list_archive_url":null,"date":"2017-09-18T18:12:15","subject":"Re: [Qemu-devel] [PATCH v8 1/4] qemu-img: add --shrink flag for\n\tresize","submitter":{"id":36836,"url":"http://patchwork.ozlabs.org/api/people/36836/","name":"Max Reitz","email":"mreitz@redhat.com"},"content":"On 2017-09-18 14:42, Pavel Butsykin wrote:\n> The flag is additional precaution against data loss. Perhaps in the future the\n> operation shrink without this flag will be blocked for all formats, but for now\n> we need to maintain compatibility with raw.\n> \n> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n> Reviewed-by: Max Reitz <mreitz@redhat.com>\n> Reviewed-by: John Snow <jsnow@redhat.com>\n> ---\n>  qemu-img-cmds.hx       |  4 ++--\n>  qemu-img.c             | 23 +++++++++++++++++++++++\n>  qemu-img.texi          |  6 +++++-\n>  tests/qemu-iotests/102 |  4 ++--\n>  tests/qemu-iotests/106 |  2 +-\n>  5 files changed, 33 insertions(+), 6 deletions(-)\n\n[...]\n\n> diff --git a/qemu-img.c b/qemu-img.c\n> index 56ef49e214..b7b2386cbd 100644\n> --- a/qemu-img.c\n> +++ b/qemu-img.c\n\n[...]\n\n> @@ -3571,6 +3577,23 @@ static int img_resize(int argc, char **argv)\n>          goto out;\n>      }\n>  \n> +    if (total_size < current_size && !shrink) {\n> +        warn_report(\"Shrinking an image will delete all data beyond the \"\n> +                    \"shrunken image's end. Before performing such an \"\n> +                    \"operation, make sure there is no important data there.\");\n> +\n> +        if (g_strcmp0(bdrv_get_format_name(blk_bs(blk)), \"raw\") != 0) {\n> +            error_report(\n> +              \"Use the --shrink option to perform a shrink operation.\");\n> +            ret = -1;\n> +            goto out;\n> +        } else {\n> +            warn_report(\"Using the --shrink option will suppress this message.\"\n\nStill missing a space here.\n\nMax\n\n> +                        \"Note that future versions of qemu-img may refuse to \"\n> +                        \"shrink images without this option.\");\n> +        }\n> +    }\n> +\n>      ret = blk_truncate(blk, total_size, prealloc, &err);\n>      if (!ret) {\n>          qprintf(quiet, \"Image resized.\\n\");","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mreitz@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwvJ45w7yz9s7B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 04:13:07 +1000 (AEST)","from localhost ([::1]:38179 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1du0XY-000414-Qh\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 14:13:04 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56250)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1du0Wz-0003s9-Qn\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 14:12:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1du0Wy-0008Lh-P4\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 14:12:29 -0400","from mx1.redhat.com ([209.132.183.28]:56736)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mreitz@redhat.com>)\n\tid 1du0Wu-0008Gi-3u; Mon, 18 Sep 2017 14:12:24 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id C98307E431;\n\tMon, 18 Sep 2017 18:12:22 +0000 (UTC)","from dresden.str.redhat.com (unknown [10.40.205.73])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id E2D925D6A6;\n\tMon, 18 Sep 2017 18:12:17 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C98307E431","To":"Pavel Butsykin <pbutsykin@virtuozzo.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170918124230.8152-1-pbutsykin@virtuozzo.com>\n\t<20170918124230.8152-2-pbutsykin@virtuozzo.com>","From":"Max Reitz <mreitz@redhat.com>","Message-ID":"<79cf9910-e76e-7c6d-f7c8-a81d84db0dd0@redhat.com>","Date":"Mon, 18 Sep 2017 20:12:15 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170918124230.8152-2-pbutsykin@virtuozzo.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"Fu5qeLNmrU7iR7qcnNSdARBfHchIRe73B\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tMon, 18 Sep 2017 18:12:23 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v8 1/4] qemu-img: add --shrink flag for\n\tresize","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, jsnow@redhat.com, armbru@redhat.com, den@openvz.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]