qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org, Alexandre Derumier <aderumier@odiso.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCHv6] add qemu-img convert -n option (skip target volume creation)
Date: Mon, 2 Sep 2013 17:28:01 +0200	[thread overview]
Message-ID: <20130902152801.GE31868@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1377890458-20877-1-git-send-email-alex@alex.org.uk>

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 <http://www.gnu.org/licenses/>.
> +#
> +
> +# 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.

  reply	other threads:[~2013-09-02 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 19:20 [Qemu-devel] [PATCHv6] add qemu-img convert -n option (skip target volume creation) Alex Bligh
2013-09-02 15:28 ` Stefan Hajnoczi [this message]
2013-09-02 18:08   ` Alex Bligh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130902152801.GE31868@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=aderumier@odiso.com \
    --cc=alex@alex.org.uk \
    --cc=aliguori@us.ibm.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).