All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: Poking around bdrv_is_inserted()
Date: Tue, 09 Nov 2021 07:44:11 +0100	[thread overview]
Message-ID: <8735o5g75w.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <87tuglg7ly.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Tue, 09 Nov 2021 07:34:33 +0100")

Screwed up qemu-devel@nongnu.org, sorry for the inconvenience.

Markus Armbruster <armbru@redhat.com> writes:

> bdrv_is_inserted() returns false when:
>
>     /**
>      * Return TRUE if the media is present
>      */
>     bool bdrv_is_inserted(BlockDriverState *bs)
>     {
>         BlockDriver *drv = bs->drv;
>         BdrvChild *child;
>
>         if (!drv) {
>             return false;
>
> 1. @bs has no driver (this is how we represent "no medium").
>
>         }
>         if (drv->bdrv_is_inserted) {
>             return drv->bdrv_is_inserted(bs);
>
> 2. Its driver's ->bdrv_is_inserted() returns false.  This is how
> passthrough block backends signal "host device has no medium".  Right
> now, the only user is "host_cdrom".
>
>         }
>         QLIST_FOREACH(child, &bs->children, next) {
>             if (!bdrv_is_inserted(child->bs)) {
>                 return false;
>
> 3. Any of its children has no medium.  Common use looking through
> filters, which have a single child.
>
>             }
>         }
>         return true;
>     }
>
> Makes sense.
>
> Now look at the uses of QERR_DEVICE_HAS_NO_MEDIUM.
>
> * external_snapshot_prepare() in blockdev.c:
>
>     if (!bdrv_is_inserted(state->old_bs)) {
>         error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
>         goto out;
>     }
>
>   where @device is the device name, i.e. BlockdevSnapshot member @node
>   or BlockdevSnapshotSync member @device.  Uh-oh: the latter can be
>   null.  If we can reach the error_setg() then, we crash on some
>   systems.
>
> * bdrv_snapshot_delete() and bdrv_snapshot_load_tmp() in
>   block/snaphot.c:
>
>     if (!drv) {
>         error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
>         return -ENOMEDIUM;
>     }
>
>   where @drv is bs->drv.
>
>   Why do we check only for 1. here instead of calling
>   bdrv_is_inserted()?



       reply	other threads:[~2021-11-09  7:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87tuglg7ly.fsf@dusky.pond.sub.org>
2021-11-09  6:44 ` Markus Armbruster [this message]
2021-11-09  9:21   ` Poking around bdrv_is_inserted() Kevin Wolf
2021-11-09 15:20     ` Markus Armbruster
2021-11-10 15:36       ` Kevin Wolf

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=8735o5g75w.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.