From nobody Sat May 18 03:46:18 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 1493214526150911.2078937555135; Wed, 26 Apr 2017 06:48:46 -0700 (PDT) Received: from localhost ([::1]:55337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NJE-0002yj-T4 for importer@patchew.org; Wed, 26 Apr 2017 09:48:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NHb-0001Vf-Sd for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3NHV-0002Ki-VW for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9675) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3NHT-0002I3-Ol; Wed, 26 Apr 2017 09:46:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A806063E12; Wed, 26 Apr 2017 13:46:54 +0000 (UTC) Received: from localhost (ovpn-204-67.brq.redhat.com [10.40.204.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16BF49652D; Wed, 26 Apr 2017 13:46:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A806063E12 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 A806063E12 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 26 Apr 2017 15:46:47 +0200 Message-Id: <20170426134649.9042-2-mreitz@redhat.com> In-Reply-To: <20170426134649.9042-1-mreitz@redhat.com> References: <20170426134649.9042-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 26 Apr 2017 13:46:54 +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 v2 1/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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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. 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 b2c4dc9613..ae6f27f899 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2049,13 +2049,15 @@ static int img_convert(int argc, char **argv) case 'W': s.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) { goto fail_getopt; } break; + } case OPTION_IMAGE_OPTS: image_opts =3D true; break; --=20 2.12.2 From nobody Sat May 18 03:46:18 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 14932147662831009.1196958199254; Wed, 26 Apr 2017 06:52:46 -0700 (PDT) Received: from localhost ([::1]:55354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NN6-0005uB-RC for importer@patchew.org; Wed, 26 Apr 2017 09:52:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NHd-0001ZV-HP for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3NHZ-0002Lt-GU for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3NHW-0002KW-1f; Wed, 26 Apr 2017 09:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3D67C05005F; Wed, 26 Apr 2017 13:46:56 +0000 (UTC) Received: from localhost (ovpn-204-67.brq.redhat.com [10.40.204.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 895039652D; Wed, 26 Apr 2017 13:46:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F3D67C05005F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F3D67C05005F From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 26 Apr 2017 15:46:48 +0200 Message-Id: <20170426134649.9042-3-mreitz@redhat.com> In-Reply-To: <20170426134649.9042-1-mreitz@redhat.com> References: <20170426134649.9042-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Apr 2017 13:46:57 +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 v2 2/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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- qemu-img.c | 13 +++++++------ tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index ae6f27f899..9eb82830f7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2089,12 +2089,6 @@ static int img_convert(int argc, char **argv) } =20 =20 - if (s.src_num > 1 && out_baseimg) { - error_report("-B makes no sense when concatenating multiple input " - "images"); - goto fail_getopt; - } - /* ret is still -EINVAL until here */ ret =3D bdrv_parse_cache_mode(src_cache, &src_flags, &src_writethrough= ); if (ret < 0) { @@ -2208,6 +2202,13 @@ static int img_convert(int argc, char **argv) } s.target_has_backing =3D (bool) out_baseimg; =20 + if (s.src_num > 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 (s.compressed) { 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 From nobody Sat May 18 03:46:18 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 1493214644736580.4608965774789; Wed, 26 Apr 2017 06:50:44 -0700 (PDT) Received: from localhost ([::1]:55348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NL9-0004T9-7n for importer@patchew.org; Wed, 26 Apr 2017 09:50:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NHe-0001be-HE for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3NHd-0002NB-DQ for qemu-devel@nongnu.org; Wed, 26 Apr 2017 09:47:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3NHY-0002LF-EX; Wed, 26 Apr 2017 09:47:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57CBC81F01; Wed, 26 Apr 2017 13:46:59 +0000 (UTC) Received: from localhost (ovpn-204-67.brq.redhat.com [10.40.204.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D64CC9328B; Wed, 26 Apr 2017 13:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57CBC81F01 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 57CBC81F01 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 26 Apr 2017 15:46:49 +0200 Message-Id: <20170426134649.9042-4-mreitz@redhat.com> In-Reply-To: <20170426134649.9042-1-mreitz@redhat.com> References: <20170426134649.9042-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 26 Apr 2017 13:46:59 +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 v2 3/3] qemu-img: Document backing options 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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" The create and convert subcommands have shorthands to set the backing_file and, in the case of create, the backing_fmt options for the new image. However, they have not been documented so far, which is remedied by this patch. Reported-by: Eric Blake Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- qemu-img-cmds.hx | 8 ++++---- qemu-img.texi | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 8ac78222af..bf4ce59019 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -22,9 +22,9 @@ STEXI ETEXI =20 DEF("create", img_create, - "create [-q] [--object objectdef] [-f fmt] [-o options] filename [size= ]") + "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backi= ng_fmt] [-o options] filename [size]") STEXI -@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-o @var{optio= ns}] @var{filename} [@var{size}] +@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backi= ng_file}] [-F @var{backing_fmt}] [-o @var{options}] @var{filename} [@var{si= ze}] ETEXI =20 DEF("commit", img_commit, @@ -40,9 +40,9 @@ STEXI ETEXI =20 DEF("convert", img_convert, - "convert [--object objectdef] [--image-opts] [-c] [-p] [-q] [-n] [-f f= mt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_id_= or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] file= name [filename2 [...]] output_filename") + "convert [--object objectdef] [--image-opts] [-c] [-p] [-q] [-n] [-f f= mt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options= ] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_cor= outines] [-W] filename [filename2 [...]] output_filename") STEXI -@item convert [--object @var{objectdef}] [--image-opts] [-c] [-p] [-q] [-n= ] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}= ] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param= }] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@v= ar{filename2} [...]] @var{output_filename} +@item convert [--object @var{objectdef}] [--image-opts] [-c] [-p] [-q] [-n= ] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}= ] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}]= [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}]= [-W] @var{filename} [@var{filename2} [...]] @var{output_filename} ETEXI =20 DEF("dd", img_dd, diff --git a/qemu-img.texi b/qemu-img.texi index c81db3e81c..8c573ae010 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -224,7 +224,7 @@ If @code{-r} is specified, exit codes representing the = image state refer to the state after (the attempt at) repairing it. That is, a successful @code{-r = all} will yield the exit code 0, independently of the image state before. =20 -@item create [-f @var{fmt}] [-o @var{options}] @var{filename} [@var{size}] +@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}]= [-o @var{options}] @var{filename} [@var{size}] =20 Create the new disk image @var{filename} of size @var{size} and format @var{fmt}. Depending on the file format, you can add one or more @var{opti= ons} @@ -302,7 +302,7 @@ Error on reading data =20 @end table =20 -@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_= cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_id_or_na= me}] [-l @var{snapshot_param}] [-m @var{num_coroutines}] [-W] [-S @var{spar= se_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_= cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-= s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-m @var{num_corouti= nes}] [-W] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @v= ar{output_filename} =20 Convert the disk image @var{filename} or a snapshot @var{snapshot_param}(@= var{snapshot_id_or_name} is deprecated) to disk image @var{output_filename} using format @var{output_fmt}. It can = be optionally compressed (@code{-c} --=20 2.12.2