summaryrefslogtreecommitdiffstats
path: root/hw/scsi
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2015-02-15 11:06:31 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2015-02-27 14:43:45 +0100
commit0543055967e554b5be10c3f96c077bf26dcaf181 (patch)
tree1bb5eb3c15e524a61b0e183a405e9066a8558df6 /hw/scsi
parent2e5b887cfc69991eee27be6cc0938c70a360fe45 (diff)
downloadhqemu-0543055967e554b5be10c3f96c077bf26dcaf181.zip
hqemu-0543055967e554b5be10c3f96c077bf26dcaf181.tar.gz
virtio-scsi-dataplane: Call blk_set_aio_context within BQL
It's not safe to call blk_set_aio_context from outside BQL because of the bdrv_drain_all there. Let's put it in the hotplug callback which will be called by qdev device realization for each scsi device attached to the bus. Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1423969591-23646-3-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi')
-rw-r--r--hw/scsi/virtio-scsi.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9e2c718..8c437dd 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -254,10 +254,8 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
int target;
int ret = 0;
- if (s->dataplane_started && blk_get_aio_context(d->conf.blk) != s->ctx) {
- aio_context_acquire(s->ctx);
- blk_set_aio_context(d->conf.blk, s->ctx);
- aio_context_release(s->ctx);
+ if (s->dataplane_started) {
+ assert(blk_get_aio_context(d->conf.blk) == s->ctx);
}
/* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */
req->resp.tmf.response = VIRTIO_SCSI_S_OK;
@@ -540,10 +538,8 @@ bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req)
virtio_scsi_complete_cmd_req(req);
return false;
}
- if (s->dataplane_started && blk_get_aio_context(d->conf.blk) != s->ctx) {
- aio_context_acquire(s->ctx);
- blk_set_aio_context(d->conf.blk, s->ctx);
- aio_context_release(s->ctx);
+ if (s->dataplane_started) {
+ assert(blk_get_aio_context(d->conf.blk) == s->ctx);
}
req->sreq = scsi_req_new(d, req->req.cmd.tag,
virtio_scsi_get_lun(req->req.cmd.lun),
@@ -767,6 +763,9 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
return;
}
blk_op_block_all(sd->conf.blk, s->blocker);
+ aio_context_acquire(s->ctx);
+ blk_set_aio_context(sd->conf.blk, s->ctx);
+ aio_context_release(s->ctx);
}
if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) {
OpenPOWER on IntegriCloud