From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] Is blk_getlength() in find_image_format() and img_map() kosher?
Date: Fri, 4 Aug 2017 10:39:24 -0500 [thread overview]
Message-ID: <fc78d5f1-f846-20f6-4880-890d03607586@redhat.com> (raw)
In-Reply-To: <87d18be8tg.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]
On 08/04/2017 08:55 AM, Markus Armbruster wrote:
> Have a look at find_image_format():
>
> if (blk_is_sg(file) || !blk_is_inserted(file) || blk_getlength(file) == 0) {
> *pdrv = &bdrv_raw;
> return ret;
> }
>
> blk_getlength() can fail. Shouldn't we error out then?
>
> We pretty obviously should in img_map():
>
> length = blk_getlength(blk);
> while (curr.start + curr.length < length) {
>
> Since I have to touch @length in the series I'm working on, I'll stick
> in a fix.
/me goes and checks my byte-based block status series
Hmm, that problem is still present even after my refactoring of
img_map(). I can rebase my series on top of your fix, as your fix
belongs in 2.10.
Alternatively, WHY do we allow blk_getlength() to fail? Are there
really situations where we can open a BDS but not know its length? I
know that we allow for online resizing detection, but presumably, either
we always know the (prior) size of the device, or we're going to have
problems talking to the device for anything beyond just a size request.
What semantics would change if we could guarantee that blk_getlength()
never failed?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
prev parent reply other threads:[~2017-08-04 15:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 13:55 [Qemu-devel] Is blk_getlength() in find_image_format() and img_map() kosher? Markus Armbruster
2017-08-04 15:39 ` Eric Blake [this message]
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=fc78d5f1-f846-20f6-4880-890d03607586@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).