d0f569
From d6956a1aaa8757fab60132c3ee46c2bb199a78a8 Mon Sep 17 00:00:00 2001
d0f569
Message-Id: <d6956a1aaa8757fab60132c3ee46c2bb199a78a8@dist-git>
9c6c51
From: John Ferlan <jferlan@redhat.com>
9c6c51
Date: Mon, 17 Dec 2018 20:42:30 -0500
9c6c51
Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
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
Add necessary checks in order to allow setting sgio values for a scsi
9c6c51
host device
9c6c51
9c6c51
Signed-off-by: John Ferlan <jferlan@redhat.com>
d0f569
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9c6c51
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9c6c51
---
d0f569
 src/qemu/qemu_conf.c | 25 ++++++++++++++++---------
d0f569
 1 file changed, 16 insertions(+), 9 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
d0f569
index 6077457ff4..ba85fc6e22 100644
9c6c51
--- a/src/qemu/qemu_conf.c
9c6c51
+++ b/src/qemu/qemu_conf.c
d0f569
@@ -1841,8 +1841,9 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
d0f569
     virDomainDiskDef *disk = NULL;
d0f569
     virDomainHostdevDef *hostdev = NULL;
fbe740
     g_autofree char *sysfs_path = NULL;
fbe740
+    g_autofree char *hostdev_path = NULL;
9c6c51
     const char *path = NULL;
d0f569
-    int val = -1;
d0f569
+    int val = 0;
fbe740
 
d0f569
     /* "sgio" is only valid for block disk; cdrom
d0f569
      * and floopy disk can have empty source.
d0f569
@@ -1858,17 +1859,14 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
d0f569
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
d0f569
         hostdev = dev->data.hostdev;
d0f569
 
d0f569
-        if (!qemuIsSharedHostdev(hostdev))
d0f569
+        if (hostdev->source.subsys.u.scsi.protocol ==
d0f569
+            VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
9c6c51
             return 0;
9c6c51
 
9c6c51
-        if (hostdev->source.subsys.u.scsi.sgio) {
9c6c51
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
9c6c51
-                           _("'sgio' is not supported for SCSI "
9c6c51
-                             "generic device yet "));
9c6c51
+        if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
fbe740
             return -1;
9c6c51
-        }
9c6c51
 
9c6c51
-        return 0;
9c6c51
+        path = hostdev_path;
9c6c51
     } else {
9c6c51
         return 0;
9c6c51
     }
d0f569
@@ -1877,7 +1875,16 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
fbe740
         return -1;
9c6c51
 
9c6c51
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
9c6c51
-    val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
d0f569
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
d0f569
+        if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
d0f569
+            val = 1;
d0f569
+    } else {
d0f569
+        /* Only settable if <shareable/> was present for hostdev */
d0f569
+        if (qemuIsSharedHostdev(hostdev) &&
d0f569
+            hostdev->source.subsys.u.scsi.sgio ==
d0f569
+            VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
d0f569
+            val = 1;
d0f569
+    }
9c6c51
 
9c6c51
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
9c6c51
      * whitelist is enabled.  But if requesting unfiltered access, always call
9c6c51
-- 
d0f569
2.34.1
9c6c51