summaryrefslogtreecommitdiff
path: root/hw/scsi/virtio-scsi.c
diff options
context:
space:
mode:
authorSergio Lopez <slp@redhat.com>2020-12-14 18:05:16 +0100
committerEric Blake <eblake@redhat.com>2021-01-20 14:48:08 -0600
commitc7040ff64ec93ee925a81d3547db925fe7d1f1c0 (patch)
tree0ff573fe23bb203ef2c770a6136f934c82e455f4 /hw/scsi/virtio-scsi.c
parentaf74b550bd8ee02c0fdeaa595d5e6f677969f39b (diff)
downloadqemu-c7040ff64ec93ee925a81d3547db925fe7d1f1c0.zip
block: Honor blk_set_aio_context() context requirements
The documentation for bdrv_set_aio_context_ignore() states this: * The caller must own the AioContext lock for the old AioContext of bs, but it * must not own the AioContext lock for new_context (unless new_context is the * same as the current context of bs). As blk_set_aio_context() makes use of this function, this rule also applies to it. Fix all occurrences where this rule wasn't honored. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Sergio Lopez <slp@redhat.com> Message-Id: <20201214170519.223781-2-slp@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'hw/scsi/virtio-scsi.c')
-rw-r--r--hw/scsi/virtio-scsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9690bc63c8..99ff261cea 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -849,15 +849,17 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
SCSIDevice *sd = SCSI_DEVICE(dev);
+ AioContext *old_context;
int ret;
if (s->ctx && !s->dataplane_fenced) {
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
return;
}
- virtio_scsi_acquire(s);
+ old_context = blk_get_aio_context(sd->conf.blk);
+ aio_context_acquire(old_context);
ret = blk_set_aio_context(sd->conf.blk, s->ctx, errp);
- virtio_scsi_release(s);
+ aio_context_release(old_context);
if (ret < 0) {
return;
}