[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 21/27] virtio-scsi: Forbid devices with different iot
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 21/27] virtio-scsi: Forbid devices with different iothreads sharing a blockdev |
Date: |
Fri, 1 Feb 2019 17:35:12 +0100 |
From: Alberto Garcia <address@hidden>
This patch forbids attaching a disk to a SCSI device if its using a
different AioContext. Test case included.
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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 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);
diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
index 5d499c9a00..65cc3b39b1 100755
--- a/tests/qemu-iotests/240
+++ b/tests/qemu-iotests/240
@@ -101,6 +101,28 @@ run_qemu <<EOF
{ "execute": "quit"}
EOF
+echo
+echo === Attach two SCSI disks using the same block device but different
iothreads ===
+echo
+
+run_qemu <<EOF
+{ "execute": "qmp_capabilities" }
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name":
"hd0", "read-only": true}}
+{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id":
"iothread0"}}
+{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id":
"iothread1"}}
+{ "execute": "device_add", "arguments": {"id": "scsi0", "driver":
"${virtio_scsi}", "iothread": "iothread0"}}
+{ "execute": "device_add", "arguments": {"id": "scsi1", "driver":
"${virtio_scsi}", "iothread": "iothread1"}}
+{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver":
"scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
+{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver":
"scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
+{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
+{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver":
"scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
+{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
+{ "execute": "device_del", "arguments": {"id": "scsi0"}}
+{ "execute": "device_del", "arguments": {"id": "scsi1"}}
+{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
+{ "execute": "quit"}
+EOF
+
# success, all done
echo "*** done"
rm -f $seq.full
diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
index 701cb5c7d2..d76392966c 100644
--- a/tests/qemu-iotests/240.out
+++ b/tests/qemu-iotests/240.out
@@ -31,4 +31,24 @@ QMP_VERSION
{"return": {}}
{"return": {}}
{"return": {}}
+
+=== Attach two SCSI disks using the same block device but different iothreads
===
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "Cannot attach a blockdev that is
using a different iothread"}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
*** done
--
2.20.1
- [Qemu-block] [PULL 11/27] iotests: Add VMDK tests for blockdev-create, (continued)
- [Qemu-block] [PULL 11/27] iotests: Add VMDK tests for blockdev-create, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 16/27] block: Apply auto-read-only for ro-whitelist drivers, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 10/27] iotests: Filter cid numbers in VMDK extent info, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 13/27] block/vpc: Don't take address of fields in packed structs, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 23/27] iotests/236: fix transaction kwarg order, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 24/27] block: Fix invalidate_cache error path for parent activation, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 03/27] qcow2: Assert that refcount block offsets fit in the refcount table, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 07/27] iotests: Make 234 stable, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 08/27] vmdk: Refactor vmdk_create_extent, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 15/27] uuid: Make qemu_uuid_bswap() take and return a QemuUUID, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 21/27] virtio-scsi: Forbid devices with different iothreads sharing a blockdev,
Kevin Wolf <=
- [Qemu-block] [PULL 09/27] vmdk: Implement .bdrv_co_create callback, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 27/27] scsi-disk: Add device_id property, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 26/27] scsi-disk: Don't use empty string as device id, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 25/27] qtest.py: Wait for the result of qtest commands, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 18/27] block: Eliminate the S_1KiB, S_2KiB, ... macros, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 14/27] block/vdi: Don't take address of fields in packed structs, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 19/27] virtio-scsi: Move BlockBackend back to the main AioContext on unplug, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 22/27] iotests: Filter second BLOCK_JOB_ERROR from 229, Kevin Wolf, 2019/02/01
- [Qemu-block] [PULL 04/27] qemu-iotests: add test case for dmg, Kevin Wolf, 2019/02/01
- Re: [Qemu-block] [Qemu-devel] [PULL 00/27] Block layer patches, no-reply, 2019/02/01