99cbc7
From f2cf0ae7bc371c75f6c0e79192711f2b1d201b10 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <f2cf0ae7bc371c75f6c0e79192711f2b1d201b10@dist-git>
99cbc7
From: John Ferlan <jferlan@redhat.com>
99cbc7
Date: Thu, 9 Jul 2015 08:28:57 -0400
99cbc7
Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1072736
99cbc7
99cbc7
RHEL-only
99cbc7
99cbc7
Add necessary checks in order to allow setting sgio values for a scsi
99cbc7
host device
99cbc7
99cbc7
Signed-off-by: John Ferlan <jferlan@redhat.com>
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_conf.c | 16 +++++++++-------
99cbc7
 1 file changed, 9 insertions(+), 7 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
99cbc7
index a4f545ef92..3ea9784854 100644
99cbc7
--- a/src/qemu/qemu_conf.c
99cbc7
+++ b/src/qemu/qemu_conf.c
99cbc7
@@ -1633,6 +1633,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
99cbc7
     virDomainDiskDefPtr disk = NULL;
99cbc7
     virDomainHostdevDefPtr hostdev = NULL;
99cbc7
     char *sysfs_path = NULL;
99cbc7
+    char *hostdev_path = NULL;
99cbc7
     const char *path = NULL;
99cbc7
     int val = -1;
99cbc7
     int ret = -1;
99cbc7
@@ -1654,14 +1655,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
99cbc7
         if (!qemuIsSharedHostdev(hostdev))
99cbc7
             return 0;
99cbc7
 
99cbc7
-        if (hostdev->source.subsys.u.scsi.sgio) {
99cbc7
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
99cbc7
-                           _("'sgio' is not supported for SCSI "
99cbc7
-                             "generic device yet "));
99cbc7
+        if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
99cbc7
             goto cleanup;
99cbc7
-        }
99cbc7
 
99cbc7
-        return 0;
99cbc7
+        path = hostdev_path;
99cbc7
     } else {
99cbc7
         return 0;
99cbc7
     }
99cbc7
@@ -1670,7 +1667,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
99cbc7
-    val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
99cbc7
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
99cbc7
+        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
99cbc7
+    else
99cbc7
+        val = (hostdev->source.subsys.u.scsi.sgio ==
99cbc7
+               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
99cbc7
 
99cbc7
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
99cbc7
      * whitelist is enabled.  But if requesting unfiltered access, always call
99cbc7
@@ -1683,6 +1684,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
99cbc7
     ret = 0;
99cbc7
 
99cbc7
  cleanup:
99cbc7
+    VIR_FREE(hostdev_path);
99cbc7
     VIR_FREE(sysfs_path);
99cbc7
     return ret;
99cbc7
 }
99cbc7
-- 
99cbc7
2.18.0
99cbc7