[libvirt] [PATCH 1/1] Fix NPIV on older kernels.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* src/node_device.c src/node_device_hal_linux.c: check in both /sys/class/fc_host/hostN and /sys/class/scsi_host/hostN for the vport operations files
---
 src/node_device.c           |   23 ++++++++++++++++++++++-
 src/node_device_hal_linux.c |   39 +++++++++++++++++++++++++++++++--------
 2 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/src/node_device.c b/src/node_device.c
index d01695d..8de6495 100644
--- a/src/node_device.c
+++ b/src/node_device.c
@@ -369,6 +369,7 @@ nodeDeviceVportCreateDelete(virConnectPtr conn,
                             int operation)
 {
     int retval = 0;
+    struct stat st;
     char *operation_path = NULL, *vport_name = NULL;
     const char *operation_file = NULL;
 
@@ -388,7 +389,7 @@ nodeDeviceVportCreateDelete(virConnectPtr conn,
     }
 
     if (virAsprintf(&operation_path,
-                    "%shost%d%s",
+                    "%s/host%d/%s",
                     LINUX_SYSFS_FC_HOST_PREFIX,
                     parent_host,
                     operation_file) < 0) {
@@ -398,6 +399,26 @@ nodeDeviceVportCreateDelete(virConnectPtr conn,
         goto cleanup;
     }
 
+    if (stat(operation_path, &st) != 0) {
+            VIR_FREE(operation_path);
+            if (virAsprintf(&operation_path,
+                            "%s/host%d/%s",
+                            LINUX_SYSFS_SCSI_HOST_PREFIX,
+                            parent_host,
+                            operation_file) < 0) {
+
+                virReportOOMError(conn);
+                retval = -1;
+                goto cleanup;
+            }
+
+            if (stat(operation_path, &st) != 0) {
+                VIR_ERROR(_("No vport operation path found for host%d"), parent_host);
+                retval = -1;
+                goto cleanup;
+            }
+    }
+
     VIR_DEBUG(_("Vport operation path is '%s'"), operation_path);
 
     if (virAsprintf(&vport_name,
diff --git a/src/node_device_hal_linux.c b/src/node_device_hal_linux.c
index b76235d..2de9afe 100644
--- a/src/node_device_hal_linux.c
+++ b/src/node_device_hal_linux.c
@@ -162,28 +162,51 @@ out:
 
 int check_vport_capable_linux(union _virNodeDevCapData *d)
 {
-    char *sysfs_path = NULL;
-    struct stat st;
     int retval = 0;
+    char *operation_path = NULL;
+    struct stat st;
 
-    if (virAsprintf(&sysfs_path, "%s/host%d/vport_create",
+    VIR_DEBUG(_("Checking if host%d is vport capable"), d->scsi_host.host);
+
+    if (virAsprintf(&operation_path,
+                    "%s/host%d/%s",
                     LINUX_SYSFS_FC_HOST_PREFIX,
-                    d->scsi_host.host) < 0) {
+                    d->scsi_host.host,
+                    LINUX_SYSFS_VPORT_CREATE_POSTFIX) < 0) {
+
         virReportOOMError(NULL);
         retval = -1;
         goto out;
     }
 
-    if (stat(sysfs_path, &st) != 0) {
-        /* Not a vport capable HBA; not an error, either. */
+    if (stat(operation_path, &st) == 0) {
+        d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS;
         goto out;
     }
 
-    d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS;
+    VIR_FREE(operation_path);
+    operation_path = NULL;
+
+    if (virAsprintf(&operation_path,
+                    "%s/host%d%s",
+                    LINUX_SYSFS_SCSI_HOST_PREFIX,
+                    d->scsi_host.host,
+                    LINUX_SYSFS_VPORT_CREATE_POSTFIX) < 0) {
+        virReportOOMError(NULL);
+        retval = -1;
+        goto out;
+    }
+
+    if (stat(operation_path, &st) == 0) {
+        d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS;
+    } else {
+        VIR_ERROR(_("No vport operation path found for host%d"), d->scsi_host.host);
+    }
 
 out:
-    VIR_FREE(sysfs_path);
+    VIR_FREE(operation_path);
     return retval;
 }
 
 #endif /* __linux__ */
+
-- 
1.6.0.6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]