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