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

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