thebeanogamer / rpms / qemu-kvm

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