]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend
authorOsier Yang <jyang@redhat.com>
Mon, 25 Mar 2013 16:43:38 +0000 (00:43 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 8 Apr 2013 10:41:06 +0000 (18:41 +0800)
It's only used by iscsi backend.

src/storage/storage_backend_iscsi.c
src/storage/storage_backend_scsi.c
src/storage/storage_backend_scsi.h

index f374961a4cfa2ee2c4889bc3fabc195d6480b513..f6b76ed4969eb6ba676910f7afef7ffb1820a594 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <config.h>
 
+#include <dirent.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <sys/types.h>
@@ -401,6 +402,42 @@ cleanup:
     return ret;
 }
 
+static int
+virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
+                                    uint32_t *host)
+{
+    int retval = 0;
+    DIR *sysdir = NULL;
+    struct dirent *dirent = NULL;
+
+    VIR_DEBUG("Finding host number from '%s'", sysfs_path);
+
+    virFileWaitForDevices();
+
+    sysdir = opendir(sysfs_path);
+
+    if (sysdir == NULL) {
+        virReportSystemError(errno,
+                             _("Failed to opendir path '%s'"), sysfs_path);
+        retval = -1;
+        goto out;
+    }
+
+    while ((dirent = readdir(sysdir))) {
+        if (STREQLEN(dirent->d_name, "target", strlen("target"))) {
+            if (sscanf(dirent->d_name,
+                       "target%u:", host) != 1) {
+                VIR_DEBUG("Failed to parse target '%s'", dirent->d_name);
+                retval = -1;
+                break;
+            }
+        }
+    }
+
+    closedir(sysdir);
+out:
+    return retval;
+}
 
 static int
 virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
@@ -416,7 +453,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
         return -1;
     }
 
-    if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) {
+    if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
         virReportSystemError(errno,
                              _("Failed to get host number for iSCSI session "
                                "with path '%s'"),
index f3ca4640374b0632900ce5e0e4ae858e83f077d7..67cb01dd8cad01337979d986c98833cbc2fb53fb 100644 (file)
@@ -547,45 +547,6 @@ out:
     return retval;
 }
 
-
-int
-virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
-                                   uint32_t *host)
-{
-    int retval = 0;
-    DIR *sysdir = NULL;
-    struct dirent *dirent = NULL;
-
-    VIR_DEBUG("Finding host number from '%s'", sysfs_path);
-
-    virFileWaitForDevices();
-
-    sysdir = opendir(sysfs_path);
-
-    if (sysdir == NULL) {
-        virReportSystemError(errno,
-                             _("Failed to opendir path '%s'"), sysfs_path);
-        retval = -1;
-        goto out;
-    }
-
-    while ((dirent = readdir(sysdir))) {
-        if (STREQLEN(dirent->d_name, "target", strlen("target"))) {
-            if (sscanf(dirent->d_name,
-                       "target%u:", host) != 1) {
-                VIR_DEBUG("Failed to parse target '%s'", dirent->d_name);
-                retval = -1;
-                break;
-            }
-        }
-    }
-
-    closedir(sysdir);
-out:
-    return retval;
-}
-
-
 static int
 virStorageBackendSCSITriggerRescan(uint32_t host)
 {
index 1cdd0da504049506a770e80d61b627d7fef76113..0984fd50318cec9e8fb0e1c7e5c8e083188312da 100644 (file)
@@ -32,9 +32,6 @@
 
 extern virStorageBackend virStorageBackendSCSI;
 
-int
-virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
-                                   uint32_t *host);
 int
 virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
                              uint32_t scanhost);