From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
Alberto Garcia <berto@igalia.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.11 3/5] block: Guard against NULL bs->drv
Date: Fri, 10 Nov 2017 15:46:08 -0600 [thread overview]
Message-ID: <e5fd7f83-b0f6-6029-6dcc-86ac132f59c4@redhat.com> (raw)
In-Reply-To: <20171110203111.7666-4-mreitz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]
On 11/10/2017 02:31 PM, Max Reitz wrote:
> We currently do not guard everywhere against a NULL bs->drv where we
> should be doing so. Most of the places fixed here just do not care
> about that case at all.
>
> Some care implicitly, e.g. through a prior function call to
> bdrv_getlength() which would always fail for an ejected BDS. Add an
> assert there to make it more obvious.
>
> Other places seem to care, but do so insufficiently: Freeing clusters in
> a qcow2 image is an error-free operation, but it may leave the image in
> an unusable state anyway. Giving qcow2_free_clusters() an error code is
> not really viable, it is much easier to note that bs->drv may be NULL
> even after a successful driver call. This concerns bdrv_co_flush(), and
> the way the check is added to bdrv_co_pdiscard() (in every iteration
> instead of only once).
>
> Finally, some places employ at least an assert(bs->drv); somewhere, that
> may be reasonable (such as in the reopen code), but in
> bdrv_has_zero_init(), it is definitely not. Returning 0 there in case
> of an ejected BDS saves us much headache instead.
>
> Reported-by: R. Nageswara Sastry <nasastry@in.ibm.com>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1728660
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> +++ b/block/replication.c
>
> + if (!s->hidden_disk->bs->drv) {
> + error_setg(errp, "Hidden disk %s is ejected",
> + s->hidden_disk->bs->node_name);
> + return;
> + }
How would the hidden disk ever be ejected? Could this be an assert instead?
But what you have is equally safe, so
Reviewed-by: Eric Blake <eblake@redhat.com>
--
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 --]
next prev parent reply other threads:[~2017-11-10 21:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 20:31 [Qemu-devel] [PATCH for-2.11 0/5] qcow2: Fixes for corrupted images Max Reitz
2017-11-10 20:31 ` [Qemu-devel] [PATCH for-2.11 1/5] qcow2: check_errors are fatal Max Reitz
2017-11-10 20:55 ` Eric Blake
2017-11-10 20:31 ` [Qemu-devel] [PATCH for-2.11 2/5] qcow2: Unaligned zero cluster in handle_alloc() Max Reitz
2017-11-10 20:58 ` Eric Blake
2017-11-14 14:55 ` Alberto Garcia
2017-11-10 20:31 ` [Qemu-devel] [PATCH for-2.11 3/5] block: Guard against NULL bs->drv Max Reitz
2017-11-10 21:46 ` Eric Blake [this message]
2017-11-14 15:36 ` Max Reitz
2017-11-10 20:31 ` [Qemu-devel] [PATCH for-2.11 4/5] qcow2: Add bounds check to get_refblock_offset() Max Reitz
2017-11-10 21:49 ` Eric Blake
2017-11-14 15:02 ` Alberto Garcia
2017-11-14 15:27 ` Max Reitz
2017-11-14 15:38 ` Alberto Garcia
2017-11-14 15:40 ` Max Reitz
2017-11-10 20:31 ` [Qemu-devel] [PATCH for-2.11 5/5] qcow2: Refuse to get unaligned offsets from cache Max Reitz
2017-11-10 21:54 ` Eric Blake
2017-11-10 22:00 ` Max Reitz
2017-11-10 22:15 ` Eric Blake
2017-11-10 22:16 ` Max Reitz
2017-11-14 15:06 ` Alberto Garcia
2017-11-14 15:09 ` Max Reitz
2017-11-14 15:31 ` Alberto Garcia
2017-11-10 20:41 ` [Qemu-devel] [PATCH for-2.11 0/5] qcow2: Fixes for corrupted images Max Reitz
2017-11-15 20:25 ` 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=e5fd7f83-b0f6-6029-6dcc-86ac132f59c4@redhat.com \
--to=eblake@redhat.com \
--cc=berto@igalia.com \
--cc=jsnow@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).