[libvirt] [PATCH 3/8] storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend

John Ferlan jferlan at redhat.com
Tue Feb 5 20:36:28 UTC 2013


On 02/04/2013 08:32 AM, Osier Yang wrote:
> It's only used by iscsi backend.
> ---
>  src/storage/storage_backend_iscsi.c |   39 ++++++++++++++++++++++++++++++++++-
>  src/storage/storage_backend_scsi.c  |   39 -----------------------------------
>  src/storage/storage_backend_scsi.h  |    3 --
>  3 files changed, 38 insertions(+), 43 deletions(-)
> 
> diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
> index f374961..da4367c 100644
> --- a/src/storage/storage_backend_iscsi.c
> +++ b/src/storage/storage_backend_iscsi.c
> @@ -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)

need one more space                  ^

> +{
> +    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'"),
> diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
> index a26bf59..257001c 100644
> --- a/src/storage/storage_backend_scsi.c
> +++ b/src/storage/storage_backend_scsi.c
> @@ -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)
>  {
> diff --git a/src/storage/storage_backend_scsi.h b/src/storage/storage_backend_scsi.h
> index 1cdd0da..0984fd5 100644
> --- a/src/storage/storage_backend_scsi.h
> +++ b/src/storage/storage_backend_scsi.h
> @@ -33,9 +33,6 @@
>  extern virStorageBackend virStorageBackendSCSI;
>  
>  int
> -virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
> -                                   uint32_t *host);
> -int
>  virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
>                               uint32_t scanhost);
>  
> 

ACK w/ the space edit.




More information about the libvir-list mailing list