qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCHv6] add qemu-img convert -n option (skip target v


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCHv6] add qemu-img convert -n option (skip target volume creation)
Date: Mon, 2 Sep 2013 17:28:01 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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 (address@hidden)
> +#
> +# 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 <http://www.gnu.org/licenses/>.
> +#
> +
> +# creator
> address@hidden
> +
> +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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]