Blame SOURCES/0027-virtio-scsi-Reject-scsi-cd-if-data-plane-enabled-RHE.patch

1bdc94
From db9aa5263282c293ffd22dd80a273590fcde92f2 Mon Sep 17 00:00:00 2001
4a2fec
From: Fam Zheng <famz@redhat.com>
4a2fec
Date: Wed, 14 Jun 2017 15:37:01 +0200
4a2fec
Subject: virtio-scsi: Reject scsi-cd if data plane enabled [RHEL only]
4a2fec
4a2fec
RH-Author: Fam Zheng <famz@redhat.com>
4a2fec
Message-id: <20170614153701.14757-1-famz@redhat.com>
4a2fec
Patchwork-id: 75613
4a2fec
O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH v3] virtio-scsi: Reject scsi-cd if data plane enabled [RHEL only]
4a2fec
Bugzilla: 1378816
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Max Reitz <mreitz@redhat.com>
4a2fec
4a2fec
We need a fix for RHEL 7.4 and 7.3.z, but unfortunately upstream isn't
4a2fec
ready. If it were, the changes will be too invasive. To have an idea:
4a2fec
4a2fec
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg05400.html
4a2fec
4a2fec
is an incomplete attempt to fix part of the issue, and the remaining
4a2fec
work unfortunately involve even more complex changes.
4a2fec
4a2fec
As a band-aid, this partially reverts the effect of ef8875b
4a2fec
(virtio-scsi: Remove op blocker for dataplane, since v2.7). We cannot
4a2fec
simply revert that commit as a whole because we already shipped it in
4a2fec
qemu-kvm-rhev 7.3, since when, block jobs has been possible.  We should
4a2fec
only block what has been broken.  Also, faithfully reverting the above
4a2fec
commit means adding back the removed op blocker, but that is not enough,
4a2fec
because it still crashes when inserting media into an initially empty
4a2fec
scsi-cd.
4a2fec
4a2fec
All in all, scsi-cd on virtio-scsi-dataplane has basically been unusable
4a2fec
unless the scsi-cd never enters an empty state, so, disable it
4a2fec
altogether.  Otherwise it would be much more difficult to avoid
4a2fec
crashing.
4a2fec
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
(cherry picked from commit b0caf00bbc35c7d89e02999bdce86e1f867728e8)
1bdc94
(cherry picked from commit c9c4f117d8b507c2f86035c282d537c0a327364f)
1bdc94
(cherry picked from commit be16f8328fe109bab1ebc8f17b16b604e6e139d8)
1bdc94
(cherry picked from commit 39884820a2d464918ea383df0519c2de0731b923)
1bdc94
(cherry picked from commit f1e2dabe06a7f4d0b5ef4c96e5ace53b9df14296)
4a2fec
---
4a2fec
 hw/scsi/virtio-scsi.c | 9 +++++++++
4a2fec
 1 file changed, 9 insertions(+)
4a2fec
4a2fec
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
1bdc94
index 3aa9971..9f754c4 100644
4a2fec
--- a/hw/scsi/virtio-scsi.c
4a2fec
+++ b/hw/scsi/virtio-scsi.c
4a2fec
@@ -790,6 +790,15 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
4a2fec
     VirtIOSCSI *s = VIRTIO_SCSI(vdev);
4a2fec
     SCSIDevice *sd = SCSI_DEVICE(dev);
4a2fec
 
4a2fec
+    /* XXX: Remove this check once block backend is capable of handling
4a2fec
+     * AioContext change upon eject/insert.
4a2fec
+     * s->ctx is NULL if ioeventfd is off, s->ctx is qemu_get_aio_context() if
4a2fec
+     * data plane is not used, both cases are safe for scsi-cd. */
4a2fec
+    if (s->ctx && s->ctx != qemu_get_aio_context() &&
4a2fec
+        object_dynamic_cast(OBJECT(dev), "scsi-cd")) {
4a2fec
+        error_setg(errp, "scsi-cd is not supported by data plane");
4a2fec
+        return;
4a2fec
+    }
4a2fec
     if (s->ctx && !s->dataplane_fenced) {
4a2fec
         if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
4a2fec
             return;
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec