mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend
It's only used by iscsi backend.
This commit is contained in:
parent
c1f63a9bdf
commit
6cf9a5bb90
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -401,6 +402,42 @@ cleanup:
|
|||||||
return ret;
|
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
|
static int
|
||||||
virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
|
virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
|
||||||
@ -416,7 +453,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) {
|
if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to get host number for iSCSI session "
|
_("Failed to get host number for iSCSI session "
|
||||||
"with path '%s'"),
|
"with path '%s'"),
|
||||||
|
@ -547,45 +547,6 @@ out:
|
|||||||
return retval;
|
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
|
static int
|
||||||
virStorageBackendSCSITriggerRescan(uint32_t host)
|
virStorageBackendSCSITriggerRescan(uint32_t host)
|
||||||
{
|
{
|
||||||
|
@ -32,9 +32,6 @@
|
|||||||
|
|
||||||
extern virStorageBackend virStorageBackendSCSI;
|
extern virStorageBackend virStorageBackendSCSI;
|
||||||
|
|
||||||
int
|
|
||||||
virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
|
|
||||||
uint32_t *host);
|
|
||||||
int
|
int
|
||||||
virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
|
virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
|
||||||
uint32_t scanhost);
|
uint32_t scanhost);
|
||||||
|
Loading…
Reference in New Issue
Block a user