qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH] vl: introduce vm_shutdown()
Date: Fri, 23 Feb 2018 16:20:44 +0800	[thread overview]
Message-ID: <20180223082044.GB31530@lemon.usersys.redhat.com> (raw)
In-Reply-To: <20180220131014.8998-1-stefanha@redhat.com>

On Tue, 02/20 13:10, Stefan Hajnoczi wrote:
> 1. virtio_scsi_handle_cmd_vq() racing with iothread_stop_all() hits the
>    virtio_scsi_ctx_check() assertion failure because the BDS AioContext
>    has been modified by iothread_stop_all().

Does this patch fix the issue completely? IIUC virtio_scsi_handle_cmd can
already be entered at the time of main thread calling virtio_scsi_clear_aio(),
so this race condition still exists:

  main thread                           iothread
-----------------------------------------------------------------------------
  vm_shutdown
    ...
      virtio_bus_stop_ioeventfd
        virtio_scsi_dataplane_stop
                                        aio_poll()
                                          ...
                                            virtio_scsi_data_plane_handle_cmd()
          aio_context_acquire(s->ctx)
                                              virtio_scsi_acquire(s).enter
          virtio_scsi_clear_aio()
          aio_context_release(s->ctx)
                                              virtio_scsi_acquire(s).return
                                              virtio_scsi_handle_cmd_vq()
                                                ...
                                                  virtqueue_pop()

Is it possible that the above virtqueue_pop() still returns one element that was
queued before vm_shutdown() was called?

If so I think we additionally need to an "s->ioeventfd_stopped" flag set in
virtio_scsi_stop_ioeventfd() and check it in
virtio_scsi_data_plane_handle_cmd().

Fam

  reply	other threads:[~2018-02-23  8:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 13:10 [Qemu-devel] [PATCH] vl: introduce vm_shutdown() Stefan Hajnoczi
2018-02-23  8:20 ` Fam Zheng [this message]
2018-02-27 15:30   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-02-28  1:58     ` Fam Zheng
2018-02-28  9:40       ` Stefan Hajnoczi

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=20180223082044.GB31530@lemon.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@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).