render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
fbe740
From fce502cf5233d800479c2efcf7721ab895db8998 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <fce502cf5233d800479c2efcf7721ab895db8998@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>
9c6c51
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9c6c51
(cherry picked from commit f2cf0ae7bc371c75f6c0e79192711f2b1d201b10)
9c6c51
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9c6c51
---
fbe740
 src/qemu/qemu_conf.c | 15 ++++++++-------
fbe740
 1 file changed, 8 insertions(+), 7 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
fbe740
index b62dd1df52..ce7869e6be 100644
9c6c51
--- a/src/qemu/qemu_conf.c
9c6c51
+++ b/src/qemu/qemu_conf.c
fbe740
@@ -1810,6 +1810,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
9c6c51
     virDomainDiskDefPtr disk = NULL;
9c6c51
     virDomainHostdevDefPtr hostdev = NULL;
fbe740
     g_autofree char *sysfs_path = NULL;
fbe740
+    g_autofree char *hostdev_path = NULL;
9c6c51
     const char *path = NULL;
9c6c51
     int val = -1;
fbe740
 
fbe740
@@ -1830,14 +1831,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
9c6c51
         if (!qemuIsSharedHostdev(hostdev))
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
     }
fbe740
@@ -1846,7 +1843,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr 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);
9c6c51
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
9c6c51
+        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
9c6c51
+    else
9c6c51
+        val = (hostdev->source.subsys.u.scsi.sgio ==
9c6c51
+               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
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
-- 
fbe740
2.25.0
9c6c51