render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
1b5f1d
From d6956a1aaa8757fab60132c3ee46c2bb199a78a8 Mon Sep 17 00:00:00 2001
1b5f1d
Message-Id: <d6956a1aaa8757fab60132c3ee46c2bb199a78a8@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
1b5f1d
index 6077457ff4..ba85fc6e22 100644
d76c62
--- a/src/qemu/qemu_conf.c
d76c62
+++ b/src/qemu/qemu_conf.c
1b5f1d
@@ -1841,8 +1841,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.
1b5f1d
@@ -1858,17 +1859,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
     }
1b5f1d
@@ -1877,7 +1875,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
-- 
1e07ec
2.34.1
d76c62