Blame SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch

d76c62
From 5a192657ad4e08fc773fef90c6b07df3620fa1c2 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <5a192657ad4e08fc773fef90c6b07df3620fa1c2@dist-git>
d76c62
From: John Ferlan <jferlan@redhat.com>
d76c62
Date: Mon, 17 Dec 2018 20:42:31 -0500
d76c62
Subject: [PATCH] RHEL: qemu: Add check for unpriv sgio for SCSI generic host
d76c62
 device
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1582424
d76c62
d76c62
RHEL-only
d76c62
d76c62
Check if the hostdev has set the sgio filtered/unfiltered and handle
d76c62
appropriately.
d76c62
d76c62
This restores functionality removed by upstream commit id 'ce346623'
d76c62
to remove sgio support for the SCSI generic host device.
d76c62
d76c62
Signed-off-by: John Ferlan <jferlan@redhat.com>
d76c62
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
d76c62
(cherry picked from commit 712005bcf26190dc6fd1fe56283377987909cc4b)
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_conf.c | 20 ++++++++++++++++++--
d76c62
 1 file changed, 18 insertions(+), 2 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
d76c62
index ce7869e6be..2a84972fd9 100644
d76c62
--- a/src/qemu/qemu_conf.c
d76c62
+++ b/src/qemu/qemu_conf.c
d76c62
@@ -1717,13 +1717,29 @@ qemuSharedHostdevAddRemoveInternal(virQEMUDriverPtr driver,
d76c62
 {
d76c62
     g_autofree char *dev_path = NULL;
d76c62
     g_autofree char *key = NULL;
d76c62
+    virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
d76c62
+    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
d76c62
     int ret = -1;
d76c62
 
d76c62
     if (!qemuIsSharedHostdev(hostdev))
d76c62
         return 0;
d76c62
 
d76c62
-    if (!(dev_path = qemuGetHostdevPath(hostdev)) ||
d76c62
-        !(key = qemuGetSharedDeviceKey(dev_path)))
d76c62
+    if (!(dev_path = qemuGetHostdevPath(hostdev)))
d76c62
+        return -1;
d76c62
+
d76c62
+    if ((ret = qemuCheckUnprivSGIO(driver->sharedDevices, dev_path,
d76c62
+                                   scsisrc->sgio)) < 0) {
d76c62
+        if (ret == -2) {
d76c62
+            virReportError(VIR_ERR_OPERATION_INVALID,
d76c62
+                           _("sgio of shared scsi host device '%s-%u-%u-%llu' "
d76c62
+                             "conflicts with other active domains"),
d76c62
+                           scsihostsrc->adapter, scsihostsrc->bus,
d76c62
+                           scsihostsrc->target, scsihostsrc->unit);
d76c62
+        }
d76c62
+        return -1;
d76c62
+    }
d76c62
+
d76c62
+    if (!(key = qemuGetSharedDeviceKey(dev_path)))
d76c62
         return -1;
d76c62
 
d76c62
     qemuDriverLock(driver);
d76c62
-- 
d76c62
2.25.0
d76c62