render / rpms / libvirt

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