From nobody Thu May 2 14:45:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14927554621091006.5929913679472; Thu, 20 Apr 2017 23:17:42 -0700 (PDT) Received: from localhost ([::1]:57367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Rsw-0005eX-Ip for importer@patchew.org; Fri, 21 Apr 2017 02:17:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Rrr-000577-Do for qemu-devel@nongnu.org; Fri, 21 Apr 2017 02:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1Rrp-0007wS-1Z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 02:16:30 -0400 Received: from mx7.zte.com.cn ([202.103.147.169]:47413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Rrm-0007nh-PF for qemu-devel@nongnu.org; Fri, 21 Apr 2017 02:16:28 -0400 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 21 Apr 2017 06:11:05 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v3L6FjYn087324; Fri, 21 Apr 2017 14:15:45 +0800 (GMT-8) (envelope-from li.ping288@zte.com.cn) Received: from localhost.localdomain ([10.74.120.79]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017042114155070-1062351 ; Fri, 21 Apr 2017 14:15:50 +0800 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170421141105 From: Ping Li To: kwolf@redhat.com, mreitz@redhat.com Date: Sat, 22 Apr 2017 06:34:32 +0800 Message-Id: <1492814072-4276-1-git-send-email-li.ping288@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-21 14:15:51, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-21 14:15:45, Serialize complete at 2017-04-21 14:15:45 X-MAIL: mse01.zte.com.cn v3L6FjYn087324 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.169 Subject: [Qemu-devel] [PATCH] Block layer core: Fix qemu-img 'amend' subcommand failure of adjusting backing file in different path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ping Li , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently, qemu-img 'amend' subcommand would fail to adjust image's backing= file which was moved into different path. For example, parent.qcow2, the backing file of leaf.qcow2, first is at /hom= e/a/, then moved into /home/b/. Originally this command, "qemu-img amend -f qcow2 -o backing_fmt=3Dqcow2,backing_file=3D/home/b/par= ent.qcow2 leaf.qcow2", would fail because qemu-img failed to open the old backing file of leaf.qc= ow2. Give the 'amend' subcommand a '-u' option to not open the old backing file while openning leaf.qcow2. Signed-off-by: Li Ping --- qemu-img.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index b220cf7..a32e9d6 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -145,9 +145,10 @@ static void QEMU_NORETURN help(void) " 'snapshot_id_or_name' is deprecated, use 'snapshot_param'\n" " instead\n" " '-c' indicates that target image must be compressed (qcow fo= rmat only)\n" - " '-u' enables unsafe rebasing. It is assumed that old and new= backing file\n" - " match exactly. The image doesn't need a working backing= file before\n" - " rebasing in this case (useful for renaming the backing = file)\n" + " '-u' enables unsafe rebasing or amending. It is assumed that= old and new\n" + " backing file match exactly. For rebasing, the image doe= sn't need a working\n" + " backing file before rebasing in this case(useful for re= naming the backing file).\n" + " For amending, it doesn't open backing file(useful for m= oving images)\n" " '-h' with or without a command shows this help and lists the= supported formats\n" " '-p' show progress of command (only certain commands)\n" " '-q' use Quiet mode - do not print any output (except errors= )\n" @@ -3538,7 +3539,7 @@ static int img_amend(int argc, char **argv) QemuOptsList *create_opts =3D NULL; QemuOpts *opts =3D NULL; const char *fmt =3D NULL, *filename, *cache; - int flags; + int flags =3D 0; bool writethrough; bool quiet =3D false, progress =3D false; BlockBackend *blk =3D NULL; @@ -3553,7 +3554,7 @@ static int img_amend(int argc, char **argv) {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":ho:f:t:pq", + c =3D getopt_long(argc, argv, ":ho:f:t:pqu", long_options, NULL); if (c =3D=3D -1) { break; @@ -3595,6 +3596,9 @@ static int img_amend(int argc, char **argv) case 'q': quiet =3D true; break; + case 'u': + flags |=3D BDRV_O_NO_BACKING; + break; case OPTION_OBJECT: opts =3D qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); @@ -3639,7 +3643,7 @@ static int img_amend(int argc, char **argv) goto out; } =20 - flags =3D BDRV_O_RDWR; + flags |=3D BDRV_O_RDWR; ret =3D bdrv_parse_cache_mode(cache, &flags, &writethrough); if (ret < 0) { error_report("Invalid cache option: %s", cache); --=20 1.8.3.1