qemu-kvm/kvm-virtio-scsi-Forbid-devices-with-different-iothreads-.patch
Danilo C. L. de Paula b705db35b7 * Mon Feb 11 2019 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 3.1.0-13.el8
- kvm-Acceptance-tests-add-Linux-initrd-checking-test.patch [bz#1669922]
- kvm-mmap-alloc-unfold-qemu_ram_mmap.patch [bz#1671519]
- kvm-mmap-alloc-fix-hugetlbfs-misaligned-length-in-ppc64.patch [bz#1671519]
- kvm-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch [bz#1653590]
- kvm-block-Fix-invalidate_cache-error-path-for-parent-act.patch [bz#1673014]
- kvm-virtio-scsi-Move-BlockBackend-back-to-the-main-AioCo.patch [bz#1656276 bz#1662508]
- kvm-scsi-disk-Acquire-the-AioContext-in-scsi_-_realize.patch [bz#1656276 bz#1662508]
- kvm-virtio-scsi-Forbid-devices-with-different-iothreads-.patch [bz#1656276 bz#1662508]
- Resolves: bz#1653590
  ([Fast train]had better stop qemu immediately while guest was making use of an improper page size)
- Resolves: bz#1656276
  (qemu-kvm core dumped after hotplug the deleted disk with iothread parameter)
- Resolves: bz#1662508
  (Qemu core dump when start guest with two disks using same drive)
- Resolves: bz#1669922
  (Backport avocado-qemu tests for QEMU 3.1)
- Resolves: bz#1671519
  (RHEL8.0 Snapshot3 - qemu doesn't free up hugepage memory when hotplug/hotunplug using memory-backend-file (qemu-kvm))
- Resolves: bz#1673014
  (Local VM and migrated VM on the same host can run with same RAW file as visual disk source while without shareable configured or lock manager enabled)
2019-02-11 14:09:54 -02:00

117 lines
4.3 KiB
Diff

From 5910975bcc4445e366399a438b811cdc8c3dd87e Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru@redhat.com>
Date: Thu, 7 Feb 2019 12:18:19 +0000
Subject: [PATCH 8/8] virtio-scsi: Forbid devices with different iothreads
sharing a blockdev
RH-Author: Markus Armbruster <armbru@redhat.com>
Message-id: <20190207121819.20092-4-armbru@redhat.com>
Patchwork-id: 84289
O-Subject: [RHEL-8.0/AV qemu-kvm PATCH 3/3] virtio-scsi: Forbid devices with different iothreads sharing a blockdev
Bugzilla: 1656276 1662508
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
From: Alberto Garcia <berto@igalia.com>
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>
(cherry picked from commit eb97813ff5fd5bdffc8ed9f5be5a3a50eae70a2c)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
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 f0d4f10..66df30d 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 <<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 701cb5c..d763929 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
--
1.8.3.1