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