|
|
ae23c9 |
From aff6f71a4e88ccec03f8451d9d9605589dddc6a2 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Date: Thu, 6 Jun 2019 19:15:24 +0100
|
|
|
ae23c9 |
Subject: [PATCH 7/8] virtio-scsi: Forbid devices with different iothreads
|
|
|
ae23c9 |
sharing a blockdev
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Message-id: <20190606191524.30797-4-armbru@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 88608
|
|
|
ae23c9 |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 3/3] virtio-scsi: Forbid devices with different iothreads sharing a blockdev
|
|
|
ae23c9 |
Bugzilla: 1673396 1673401
|
|
|
ae23c9 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Alberto Garcia <berto@igalia.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This patch forbids attaching a disk to a SCSI device if its using a
|
|
|
ae23c9 |
different AioContext. Test case included.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Alberto Garcia <berto@igalia.com>
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit eb97813ff5fd5bdffc8ed9f5be5a3a50eae70a2c)
|
|
|
ae23c9 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
hw/scsi/virtio-scsi.c | 7 +++++++
|
|
|
ae23c9 |
tests/qemu-iotests/240 | 22 ++++++++++++++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/240.out | 20 ++++++++++++++++++++
|
|
|
ae23c9 |
3 files changed, 49 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
index 85073f6..391500b 100644
|
|
|
ae23c9 |
--- a/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
+++ b/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
@@ -800,9 +800,16 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
if (s->ctx && !s->dataplane_fenced) {
|
|
|
ae23c9 |
+ AioContext *ctx;
|
|
|
ae23c9 |
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
+ ctx = blk_get_aio_context(sd->conf.blk);
|
|
|
ae23c9 |
+ if (ctx != s->ctx && ctx != qemu_get_aio_context()) {
|
|
|
ae23c9 |
+ error_setg(errp, "Cannot attach a blockdev that is using "
|
|
|
ae23c9 |
+ "a different iothread");
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
virtio_scsi_acquire(s);
|
|
|
ae23c9 |
blk_set_aio_context(sd->conf.blk, s->ctx);
|
|
|
ae23c9 |
virtio_scsi_release(s);
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
|
|
|
ae23c9 |
index 5d499c9..65cc3b3 100755
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/240
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/240
|
|
|
ae23c9 |
@@ -101,6 +101,28 @@ run_qemu <
|
|
|
ae23c9 |
{ "execute": "quit"}
|
|
|
ae23c9 |
EOF
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
+echo === Attach two SCSI disks using the same block device but different iothreads ===
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+run_qemu <
|
|
|
ae23c9 |
+{ "execute": "qmp_capabilities" }
|
|
|
ae23c9 |
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}}
|
|
|
ae23c9 |
+{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
|
|
|
ae23c9 |
+{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi1"}}
|
|
|
ae23c9 |
+{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
|
|
|
ae23c9 |
+{ "execute": "quit"}
|
|
|
ae23c9 |
+EOF
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
# success, all done
|
|
|
ae23c9 |
echo "*** done"
|
|
|
ae23c9 |
rm -f $seq.full
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
|
|
|
ae23c9 |
index 701cb5c..d763929 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/240.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/240.out
|
|
|
ae23c9 |
@@ -31,4 +31,24 @@ QMP_VERSION
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+=== Attach two SCSI disks using the same block device but different iothreads ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing:
|
|
|
ae23c9 |
+QMP_VERSION
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"error": {"class": "GenericError", "desc": "Cannot attach a blockdev that is using a different iothread"}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
*** done
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|