From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Max Reitz <mreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-io: Respect early image end for map
Date: Sat, 11 Oct 2014 20:47:38 +0200 [thread overview]
Message-ID: <20141011184737.GB7688@irqsave.net> (raw)
In-Reply-To: <1408215258-12545-3-git-send-email-mreitz@redhat.com>
The Saturday 16 Aug 2014 à 20:54:17 (+0200), Max Reitz wrote :
> bdrv_is_allocated() may report zero clusters which most probably means
> the image (file) is shorter than expected. Respect this case in order to
> avoid an infinite loop.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> qemu-io-cmds.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
> index c503fc6..860b834 100644
> --- a/qemu-io-cmds.c
> +++ b/qemu-io-cmds.c
> @@ -1909,7 +1909,7 @@ static int map_is_allocated(BlockDriverState *bs, int64_t sector_num,
>
> num_checked = MIN(nb_sectors, INT_MAX);
> ret = bdrv_is_allocated(bs, sector_num, num_checked, &num);
> - if (ret == firstret) {
> + if (ret == firstret && num) {
> *pnum += num;
> } else {
> break;
> @@ -1936,6 +1936,9 @@ static int map_f(BlockDriverState *bs, int argc, char **argv)
> if (ret < 0) {
> error_report("Failed to get allocation status: %s", strerror(-ret));
> return 0;
> + } else if (!num) {
> + error_report("Unexpected end of image");
> + return 0;
> }
>
> retstr = ret ? " allocated" : "not allocated";
> --
> 2.0.4
>
>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
next prev parent reply other threads:[~2014-10-11 18:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-16 18:54 [Qemu-devel] [PATCH 0/3] block: Fix is_allocated() for truncated images Max Reitz
2014-08-16 18:54 ` [Qemu-devel] [PATCH 1/3] block: Ignore allocation size in underlying file Max Reitz
2014-10-08 21:29 ` Eric Blake
2014-10-10 11:50 ` Benoît Canet
2014-10-11 9:44 ` Max Reitz
2014-10-11 18:48 ` Benoît Canet
2014-08-16 18:54 ` [Qemu-devel] [PATCH 2/3] qemu-io: Respect early image end for map Max Reitz
2014-10-09 4:17 ` Eric Blake
2014-10-10 12:03 ` Benoît Canet
2014-10-11 9:53 ` Max Reitz
2014-10-11 18:46 ` Benoît Canet
2014-10-11 18:47 ` Benoît Canet [this message]
2014-08-16 18:54 ` [Qemu-devel] [PATCH 3/3] iotests: Add test for map commands Max Reitz
2014-10-09 4:18 ` Eric Blake
2014-10-08 19:32 ` [Qemu-devel] [PATCH 0/3] block: Fix is_allocated() for truncated images Max Reitz
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=20141011184737.GB7688@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=kwolf@redhat.com \
--cc=mreitz@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).