From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH for-2.9] virtio-scsi: Fix assertion failure on dataplane handlers
Date: Tue, 14 Mar 2017 21:26:54 +0800 [thread overview]
Message-ID: <20170314132654.6751-1-famz@redhat.com> (raw)
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Signed-off-by: Fam Zheng <famz@redhat.com>
---
hw/scsi/virtio-scsi-dataplane.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 74c95e0..12b44b7 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -52,28 +52,40 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
static bool virtio_scsi_data_plane_handle_cmd(VirtIODevice *vdev,
VirtQueue *vq)
{
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
+ bool progress;
+ VirtIOSCSI *s = VIRTIO_SCSI(vdev);
+ aio_context_acquire(s->ctx);
assert(s->ctx && s->dataplane_started);
- return virtio_scsi_handle_cmd_vq(s, vq);
+ progress = virtio_scsi_handle_cmd_vq(s, vq);
+ aio_context_release(s->ctx);
+ return progress;
}
static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
VirtQueue *vq)
{
+ bool progress;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
+ aio_context_acquire(s->ctx);
assert(s->ctx && s->dataplane_started);
- return virtio_scsi_handle_ctrl_vq(s, vq);
+ progress = virtio_scsi_handle_ctrl_vq(s, vq);
+ aio_context_release(s->ctx);
+ return progress;
}
static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
+ bool progress;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
+ aio_context_acquire(s->ctx);
assert(s->ctx && s->dataplane_started);
- return virtio_scsi_handle_event_vq(s, vq);
+ progress = virtio_scsi_handle_event_vq(s, vq);
+ aio_context_release(s->ctx);
+ return progress;
}
static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
--
2.9.3
next reply other threads:[~2017-03-14 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 13:26 Fam Zheng [this message]
2017-03-14 13:28 ` [Qemu-devel] [PATCH for-2.9] virtio-scsi: Fix assertion failure on dataplane handlers Paolo Bonzini
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=20170314132654.6751-1-famz@redhat.com \
--to=famz@redhat.com \
--cc=pbonzini@redhat.com \
--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).