From aff6f71a4e88ccec03f8451d9d9605589dddc6a2 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 6 Jun 2019 19:15:24 +0100 Subject: [PATCH 7/8] virtio-scsi: Forbid devices with different iothreads sharing a blockdev RH-Author: Markus Armbruster Message-id: <20190606191524.30797-4-armbru@redhat.com> Patchwork-id: 88608 O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 3/3] virtio-scsi: Forbid devices with different iothreads sharing a blockdev Bugzilla: 1673396 1673401 RH-Acked-by: Paolo Bonzini RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Kevin Wolf From: Alberto Garcia This patch forbids attaching a disk to a SCSI device if its using a different AioContext. Test case included. Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf (cherry picked from commit eb97813ff5fd5bdffc8ed9f5be5a3a50eae70a2c) Signed-off-by: Markus Armbruster Signed-off-by: Danilo C. L. de Paula --- hw/scsi/virtio-scsi.c | 7 +++++++ tests/qemu-iotests/240 | 22 ++++++++++++++++++++++ tests/qemu-iotests/240.out | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 85073f6..391500b 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -800,9 +800,16 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, return; } 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); diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240 index 5d499c9..65cc3b3 100755 --- a/tests/qemu-iotests/240 +++ b/tests/qemu-iotests/240 @@ -101,6 +101,28 @@ run_qemu <