qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCHv4 1/2] qemu-img: find the image end offset durin


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCHv4 1/2] qemu-img: find the image end offset during check
Date: Mon, 28 Jan 2013 10:53:40 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 01/28/2013 04:59 AM, Federico Simoncelli wrote:
> This patch adds the support for reporting the image end offset (in
> bytes). This is particularly useful after a conversion (or a rebase)
> where the destination is a block device in order to find the first
> unused byte at the end of the image.
> 
> Signed-off-by: Federico Simoncelli <address@hidden>
> ---
>  block/qcow2-refcount.c       |   10 ++++++++--
>  include/block/block.h        |    1 +
>  qemu-img.c                   |    4 ++++
>  tests/qemu-iotests/026       |    6 +++---
>  tests/qemu-iotests/036       |    3 ++-
>  tests/qemu-iotests/039       |    2 +-
>  tests/qemu-iotests/044.out   |    1 +
>  tests/qemu-iotests/common.rc |    5 +++--
>  8 files changed, 23 insertions(+), 9 deletions(-)

> +++ b/tests/qemu-iotests/common.rc
> @@ -161,9 +161,10 @@ _cleanup_test_img()
>  
>  _check_test_img()
>  {
> -    $QEMU_IMG check -f $IMGFMT $TEST_IMG 2>&1 | \
> +    $QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \
>          grep -v "fragmented$" | \
> -     sed -e 's/qemu-img\: This image format does not support checks/No 
> errors were found on the image./'
> +     sed -e 's/qemu-img\: This image format does not support checks/No 
> errors were found on the image./' | \

Pre-existing, but '\:' is not portable in sed; better is using ':' directly.

> +     sed -e '/Image end offset: [0-9]\+/d'
>  }

'sed -e | sed -e' is a waste of a process.  Why not use a single sed for
both operations?  For that matter, since we are already using sed, why
not use it in place of 'grep -v'?

Use of '[0-9]\+' is not portable in all versions of sed. Better would
be: '[0-9][0-9]*'.  Then again, since you aren't anchoring the
expression, you don't really care whether there was more than one digit;
you still end up deleting the entire line.

Thus, a simpler version would be:

$QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \
sed -e '/fragmented$/d' \
    -e 's/qemu-img\: This image format does not support checks/No errors
were found on the image./' \
    -e /Image end offset: [0-9]/d'

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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