[libvirt] [PATCH v2 09/10] qemu: Add ability to set sgio values for hostdev

John Ferlan jferlan at redhat.com
Mon Jul 6 17:08:37 UTC 2015


Add necessary checks in order to allow setting sgio values for a scsi
host device

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_conf.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 589a6cf..7df971b 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1446,6 +1446,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
     virDomainDiskDefPtr disk = NULL;
     virDomainHostdevDefPtr hostdev = NULL;
     char *sysfs_path = NULL;
+    char *hostdev_path = NULL;
     const char *path = NULL;
     bool val = false;
     int ret = -1;
@@ -1467,13 +1468,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
         if (!qemuIsSharedHostdev(hostdev))
             return 0;
 
-        if (hostdev->source.subsys.u.scsi.sgio)
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("'sgio' is not supported for SCSI "
-                             "generic device yet "));
+        if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
             goto cleanup;
 
-        return 0;
+        path = hostdev_path;
     } else {
         return 0;
     }
@@ -1482,7 +1480,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
         goto cleanup;
 
     /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0.  */
-    val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK)
+        val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
+    else
+        val = (hostdev->source.subsys.u.scsi.sgio ==
+               VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
 
     /* Do not do anything if unpriv_sgio is not supported by the kernel and the
      * whitelist is enabled.  But if requesting unfiltered access, always call
@@ -1499,6 +1501,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
     ret = 0;
 
  cleanup:
+    VIR_FREE(hostdev_path);
     VIR_FREE(sysfs_path);
     return ret;
 }
-- 
2.1.0




More information about the libvir-list mailing list