qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Hanna Czenczek <hreitz@redhat.com>
Cc: qemu-block@nongnu.org, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] block: Fix locking in media change monitor commands
Date: Tue, 31 Oct 2023 13:50:32 +0100	[thread overview]
Message-ID: <ZUD4GI7YfYpSe29m@redhat.com> (raw)
In-Reply-To: <7dd7cca5-6706-4ecd-9d5b-cc0133053d86@redhat.com>

Am 31.10.2023 um 12:54 hat Hanna Czenczek geschrieben:
> On 13.10.23 17:33, Kevin Wolf wrote:
> > blk_insert_bs() requires that the caller holds the AioContext lock for
> > the node to be inserted. Since commit c066e808e11, neglecting to do so
> > causes a crash when the child has to be moved to a different AioContext
> > to attach it to the BlockBackend.
> > 
> > This fixes qmp_blockdev_insert_anon_medium(), which is called for the
> > QMP commands 'blockdev-insert-medium' and 'blockdev-change-medium', to
> > correctly take the lock.
> > 
> > Cc: qemu-stable@nongnu.org
> > Fixes: https://issues.redhat.com/browse/RHEL-3922
> > Fixes: c066e808e11a5c181b625537b6c78e0de27a4801
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >   block/qapi-sysemu.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> 
> Do we need to take the lock for the dev_ops tray callbacks, too?  I suppose
> not, and it also wouldn’t really matter in light of the lock being supposed
> to go away anyway, but still thought I should ask.

Seems nobody ever bothered to define what the callbacks expects, and I
don't know either. Not taking the lock can obviously be a problem, but
taking it can also be a problem if the callback then locks a second time
and calls a synchronous function that polls.

What I do see is that callers disagree about this, so no matter what the
correct answer is, I'm almost sure there is a bug hiding somewhere.

Kevin



  reply	other threads:[~2023-10-31 12:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 15:33 [PATCH 0/2] block: Fix locking in media change monitor commands Kevin Wolf
2023-10-13 15:33 ` [PATCH 1/2] " Kevin Wolf
2023-10-31 11:54   ` Hanna Czenczek
2023-10-31 12:50     ` Kevin Wolf [this message]
2023-10-13 15:33 ` [PATCH 2/2] iotests: Test media change with iothreads Kevin Wolf
2023-10-31 11:55   ` Hanna Czenczek

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=ZUD4GI7YfYpSe29m@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).