render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From fce502cf5233d800479c2efcf7721ab895db8998 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <fce502cf5233d800479c2efcf7721ab895db8998@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
---
a41c76
 src/qemu/qemu_conf.c | 15 ++++++++-------
a41c76
 1 file changed, 8 insertions(+), 7 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
a41c76
index b62dd1df52..ce7869e6be 100644
edecca
--- a/src/qemu/qemu_conf.c
edecca
+++ b/src/qemu/qemu_conf.c
a41c76
@@ -1810,6 +1810,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
edecca
     virDomainDiskDefPtr disk = NULL;
edecca
     virDomainHostdevDefPtr hostdev = NULL;
a41c76
     g_autofree char *sysfs_path = NULL;
a41c76
+    g_autofree char *hostdev_path = NULL;
edecca
     const char *path = NULL;
edecca
     int val = -1;
a41c76
 
a41c76
@@ -1830,14 +1831,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)))
a41c76
             return -1;
edecca
-        }
edecca
 
edecca
-        return 0;
edecca
+        path = hostdev_path;
edecca
     } else {
edecca
         return 0;
edecca
     }
a41c76
@@ -1846,7 +1843,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
a41c76
         return -1;
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
-- 
a41c76
2.25.0
edecca