render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
edecca
From 2d4b19613c462e876ee1327d600f5cbbb998c540 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <2d4b19613c462e876ee1327d600f5cbbb998c540@dist-git>
edecca
From: John Ferlan <jferlan@redhat.com>
edecca
Date: Mon, 17 Dec 2018 20:42:30 -0500
edecca
Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1582424
edecca
edecca
RHEL-only
edecca
edecca
Add necessary checks in order to allow setting sgio values for a scsi
edecca
host device
edecca
edecca
Signed-off-by: John Ferlan <jferlan@redhat.com>
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
(cherry picked from commit f2cf0ae7bc371c75f6c0e79192711f2b1d201b10)
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_conf.c | 16 +++++++++-------
edecca
 1 file changed, 9 insertions(+), 7 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
edecca
index a4f545ef92..3ea9784854 100644
edecca
--- a/src/qemu/qemu_conf.c
edecca
+++ b/src/qemu/qemu_conf.c
edecca
@@ -1633,6 +1633,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
     virDomainDiskDefPtr disk = NULL;
edecca
     virDomainHostdevDefPtr hostdev = NULL;
edecca
     char *sysfs_path = NULL;
edecca
+    char *hostdev_path = NULL;
edecca
     const char *path = NULL;
edecca
     int val = -1;
edecca
     int ret = -1;
edecca
@@ -1654,14 +1655,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
         if (!qemuIsSharedHostdev(hostdev))
edecca
             return 0;
edecca
 
edecca
-        if (hostdev->source.subsys.u.scsi.sgio) {
edecca
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
edecca
-                           _("'sgio' is not supported for SCSI "
edecca
-                             "generic device yet "));
edecca
+        if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
edecca
             goto cleanup;
edecca
-        }
edecca
 
edecca
-        return 0;
edecca
+        path = hostdev_path;
edecca
     } else {
edecca
         return 0;
edecca
     }
edecca
@@ -1670,7 +1667,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
         goto cleanup;
edecca
 
edecca
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
edecca
-    val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
edecca
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
edecca
+        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
edecca
+    else
edecca
+        val = (hostdev->source.subsys.u.scsi.sgio ==
edecca
+               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
edecca
 
edecca
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
edecca
      * whitelist is enabled.  But if requesting unfiltered access, always call
edecca
@@ -1683,6 +1684,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
     ret = 0;
edecca
 
edecca
  cleanup:
edecca
+    VIR_FREE(hostdev_path);
edecca
     VIR_FREE(sysfs_path);
edecca
     return ret;
edecca
 }
edecca
-- 
edecca
2.20.1
edecca