From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGW30-0001YN-7p for qemu-devel@nongnu.org; Mon, 02 Sep 2013 11:28:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGW2v-0001IE-DG for qemu-devel@nongnu.org; Mon, 02 Sep 2013 11:28:10 -0400 Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]:55092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGW2v-0001I0-61 for qemu-devel@nongnu.org; Mon, 02 Sep 2013 11:28:05 -0400 Received: by mail-ea0-f179.google.com with SMTP id b10so2385958eae.24 for ; Mon, 02 Sep 2013 08:28:04 -0700 (PDT) Date: Mon, 2 Sep 2013 17:28:01 +0200 From: Stefan Hajnoczi Message-ID: <20130902152801.GE31868@stefanha-thinkpad.redhat.com> References: <1377890458-20877-1-git-send-email-alex@alex.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1377890458-20877-1-git-send-email-alex@alex.org.uk> Subject: Re: [Qemu-devel] [PATCHv6] add qemu-img convert -n option (skip target volume creation) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Anthony Liguori , Fam Zheng , qemu-devel@nongnu.org, Alexandre Derumier , Stefan Hajnoczi , Paolo Bonzini On Fri, Aug 30, 2013 at 08:20:58PM +0100, Alex Bligh wrote: > @@ -1363,6 +1372,16 @@ static int img_convert(int argc, char **argv) > bdrv_get_geometry(bs[0], &bs_sectors); > buf = qemu_blockalign(out_bs, IO_BUF_SIZE); > > + if (skip_create) { > + uint64_t out_bs_sectors = 0; > + bdrv_get_geometry(out_bs, &out_bs_sectors); > + if (out_bs_sectors < total_sectors) { > + error_report("output file is smaller than input file"); If bdrv_getlength() failed and bdrv_get_geometry() produced a 0 result, then this error message will be confusing to users. It would be better to use bdrv_getlength() directly: int64_t length = bdrv_getlength(out_bs); if (length < 0) { error_report("unable to get output image length: %s\n", strerror(-length)); ret = -1; goto out; } else if (length < total_sectors) { error_report("output file is smaller than input file"); ret = -1; goto out; } > diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 > new file mode 100755 > index 0000000..52f73d4 > --- /dev/null > +++ b/tests/qemu-iotests/060 > @@ -0,0 +1,102 @@ > +#!/bin/bash > +# > +# test of qemu-img convert -n - convert without creation > +# > +# Copyright (C) 2009 Red Hat, Inc. > +# Copyright (C) 2013 Alex Bligh (alex@alex.org.uk) > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 2 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > +# > + > +# creator > +owner=alex@alex.org.uk > + > +seq=`basename $0` > +echo "QA output created by $seq" > + > +here=`pwd` > +tmp=/tmp/$$ > +status=1 # failure is the default! > + > +_cleanup() > +{ > + _cleanup_test_img > + rm -f $TEST_IMG.orig $TEST_IMG.raw $TEST_IMG.raw2 > +} > +trap "_cleanup; exit \$status" 0 1 2 3 15 > + > +# get standard environment, filters and checks > +. ./common.rc > +. ./common.filter > +. ./common.pattern > + > +# much of this could be generic for any format supporting compression. Compression? > +_supported_fmt qcow qcow2 vmdk qed raw > +_supported_proto generic > +_supported_os Linux > + > +TEST_OFFSETS="0 4294967296" > +TEST_OPS="writev read write readv" > +CLUSTER_SIZE=4096 Unused variables.