From patchwork Wed Apr 26 13:46:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 9701423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 825FE60245 for ; Wed, 26 Apr 2017 13:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73D5F201A4 for ; Wed, 26 Apr 2017 13:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66DCC20572; Wed, 26 Apr 2017 13:52:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 18978201A4 for ; Wed, 26 Apr 2017 13:52:18 +0000 (UTC) Received: from localhost ([::1]:55350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3NMf-00058d-CE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Apr 2017 09:52:17 -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) 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 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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=X 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) } - 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 = 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 = (bool) out_baseimg; + 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 = -1; + goto out; + } + /* Check if compression is supported */ if (s.compressed) { bool encryption = 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 concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images === Compression with misaligned allocations and image sizes ===