aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2019-01-22 17:53:23 +0200
committerKevin Wolf <kwolf@redhat.com>2019-02-01 13:46:45 +0100
commiteb97813ff5fd5bdffc8ed9f5be5a3a50eae70a2c (patch)
treef8d1d98e37df7014da91b12407133962f11e47f7 /hw/scsi
parent3ff35ba391134e4e43ab96152deb38a62e62f858 (diff)
virtio-scsi: Forbid devices with different iothreads sharing a blockdev
This patch forbids attaching a disk to a SCSI device if its using a different AioContext. Test case included. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/scsi')
-rw-r--r--hw/scsi/virtio-scsi.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index e1f7b208c7..eb90288f47 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -791,9 +791,16 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
SCSIDevice *sd = SCSI_DEVICE(dev);
if (s->ctx && !s->dataplane_fenced) {
+ AioContext *ctx;
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
return;
}
+ ctx = blk_get_aio_context(sd->conf.blk);
+ if (ctx != s->ctx && ctx != qemu_get_aio_context()) {
+ error_setg(errp, "Cannot attach a blockdev that is using "
+ "a different iothread");
+ return;
+ }
virtio_scsi_acquire(s);
blk_set_aio_context(sd->conf.blk, s->ctx);
virtio_scsi_release(s);