From nobody Sat May 4 12:21:10 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 1492115738709245.76208982641663; Thu, 13 Apr 2017 13:35:38 -0700 (PDT) Received: from localhost ([::1]:50816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylSr-0004Pe-Co for importer@patchew.org; Thu, 13 Apr 2017 16:35:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylRT-0003M3-Qo for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cylRT-0002Km-2l for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cylRP-0002Gz-6z; Thu, 13 Apr 2017 16:34:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D1984E326; Thu, 13 Apr 2017 20:34:06 +0000 (UTC) Received: from localhost (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4080179D7; Thu, 13 Apr 2017 20:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D1984E326 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D1984E326 From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Apr 2017 22:33:59 +0200 Message-Id: <20170413203401.3213-2-mreitz@redhat.com> In-Reply-To: <20170413203401.3213-1-mreitz@redhat.com> References: <20170413203401.3213-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 13 Apr 2017 20:34:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 1/3] qemu-img/convert: Always set ret < 0 on error 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: Kevin Wolf , qemu-stable , qemu-devel@nongnu.org, Max Reitz 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" Otherwise the qemu-img process will exit with EXIT_SUCCESS instead of EXIT_FAILURE. Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 37c2894678..f2809e1ab4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2069,6 +2069,7 @@ static int img_convert(int argc, char **argv) opts =3D qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { + ret =3D -1; goto fail_getopt; } break; @@ -2081,6 +2082,7 @@ static int img_convert(int argc, char **argv) if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { + ret =3D -1; goto fail_getopt; } =20 --=20 2.12.2 From nobody Sat May 4 12:21:10 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 1492115738712513.9004906771328; Thu, 13 Apr 2017 13:35:38 -0700 (PDT) Received: from localhost ([::1]:50817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylSr-0004Pk-7s for importer@patchew.org; Thu, 13 Apr 2017 16:35:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylRU-0003MZ-K6 for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cylRT-0002LN-Jc for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cylRR-0002Ik-GO; Thu, 13 Apr 2017 16:34:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7330DC05974C; Thu, 13 Apr 2017 20:34:08 +0000 (UTC) Received: from localhost (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F2CE21899C; Thu, 13 Apr 2017 20:34:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7330DC05974C Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7330DC05974C From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Apr 2017 22:34:00 +0200 Message-Id: <20170413203401.3213-3-mreitz@redhat.com> In-Reply-To: <20170413203401.3213-1-mreitz@redhat.com> References: <20170413203401.3213-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 13 Apr 2017 20:34:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 2/3] qemu-img/convert: Use @opts for one thing only 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: Kevin Wolf , qemu-stable , qemu-devel@nongnu.org, Max Reitz 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" After storing the creation options for the new image into @opts, we fetch some things for our own information, like the backing file name, or whether to use encryption or preallocation. With the -n parameter, there will not be any creation options; this is not too bad because this just means that querying a NULL @opts will always return the default value. However, we also use @opts for the --object options. Therefore, @opts is not necessarily NULL if -n was specified; instead, it may contain those options. In practice, this probably does not cause any problems because there most likely is no object that supports any of the parameters we query here, but this is neither something we should rely on nor does this variable reuse make the code very nice to read. Therefore, just use an own variable for the --object options. Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- qemu-img.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index f2809e1ab4..70ffb07447 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2065,14 +2065,16 @@ static int img_convert(int argc, char **argv) case 'W': wr_in_order =3D false; break; - case OPTION_OBJECT: - opts =3D qemu_opts_parse_noisily(&qemu_object_opts, - optarg, true); - if (!opts) { + case OPTION_OBJECT: { + QemuOpts *object_opts; + object_opts =3D qemu_opts_parse_noisily(&qemu_object_opts, + optarg, true); + if (!object_opts) { ret =3D -1; goto fail_getopt; } break; + } case OPTION_IMAGE_OPTS: image_opts =3D true; break; --=20 2.12.2 From nobody Sat May 4 12:21:10 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 1492115856226256.5308788351281; Thu, 13 Apr 2017 13:37:36 -0700 (PDT) Received: from localhost ([::1]:50825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylUk-00064p-Mv for importer@patchew.org; Thu, 13 Apr 2017 16:37:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cylRb-0003TL-CC for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cylRW-0002OX-7g for qemu-devel@nongnu.org; Thu, 13 Apr 2017 16:34:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cylRT-0002Ky-QU; Thu, 13 Apr 2017 16:34:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE7AC80516; Thu, 13 Apr 2017 20:34:10 +0000 (UTC) Received: from localhost (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 526BB627DD; Thu, 13 Apr 2017 20:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE7AC80516 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BE7AC80516 From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Apr 2017 22:34:01 +0200 Message-Id: <20170413203401.3213-4-mreitz@redhat.com> In-Reply-To: <20170413203401.3213-1-mreitz@redhat.com> References: <20170413203401.3213-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 13 Apr 2017 20:34:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 3/3] qemu-img/convert: Move bs_n > 1 && -B check down 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: Kevin Wolf , qemu-stable , qemu-devel@nongnu.org, Max Reitz 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" It does not make much sense to use a backing image for the target when you concatenate multiple images (because then there is no correspondence between the source images' backing files and the target's); but it was still possible to give one by using -o backing_file=3DX instead of -B X. Fix this by moving the check. (Also, change the error message because -B is not the only way to specify the backing file, evidently.) Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- qemu-img.c | 14 +++++++------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 70ffb07447..cfd1986efd 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2113,13 +2113,6 @@ static int img_convert(int argc, char **argv) } =20 =20 - if (bs_n > 1 && out_baseimg) { - error_report("-B makes no sense when concatenating multiple input " - "images"); - ret =3D -1; - goto out; - } - src_flags =3D 0; ret =3D bdrv_parse_cache_mode(src_cache, &src_flags, &src_writethrough= ); if (ret < 0) { @@ -2229,6 +2222,13 @@ static int img_convert(int argc, char **argv) out_baseimg =3D out_baseimg_param; } =20 + if (bs_n > 1 && out_baseimg) { + error_report("Having a backing file for the target makes no sense = when " + "concatenating multiple input images"); + ret =3D -1; + goto out; + } + /* Check if compression is supported */ if (compress) { bool encryption =3D diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 98814de5d6..9317d801ad 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -61,8 +61,8 @@ read 65536/65536 bytes at offset 4194304 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 8388608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: -B makes no sense when concatenating multiple input images -qemu-img: -B makes no sense when concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concate= nating multiple input images +qemu-img: Having a backing file for the target makes no sense when concate= nating multiple input images =20 =3D=3D=3D Compression with misaligned allocations and image sizes =3D=3D= =3D =20 --=20 2.12.2