Allow iser:// style URLs

Let user specify iSER support by the protocol part of the URL.

I.e. support both
iser://127.0.0.1/iqn.ronnie.test/1

iscsi://127.0.0.1/iqn.ronnie.test/1?iser

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-09-02 16:40:24 -07:00
parent 8f41a629ec
commit e0fd6dc051
2 changed files with 16 additions and 2 deletions

2
README
View File

@@ -34,6 +34,8 @@ iSCSI URL Format
================
iSCSI devices are specified by a URL format of the following form :
iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>[?<argument>[&<argument>]*]
or
iser://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>[?<argument>[&<argument>]*]
Arguments:
Username and password for bidirectional CHAP authentication:

View File

@@ -520,7 +520,11 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
int is_iser = 0;
#endif
if (strncmp(url, "iscsi://", 8)) {
if (strncmp(url, "iscsi://", 8)
#ifdef HAVE_LINUX_ISER
&& strncmp(url, "iser://", 7)
#endif
) {
if (full) {
iscsi_set_error(iscsi, "Invalid URL %s\niSCSI URL must "
"be of the form: %s",
@@ -533,7 +537,15 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
return NULL;
}
strncpy(str,url + 8, MAX_STRING_SIZE);
#ifdef HAVE_LINUX_ISER
if (!strncmp(url, "iser://", 7)) {
is_iser = 1;
strncpy(str, url + 7, MAX_STRING_SIZE);
}
#endif
if (!strncmp(url, "iscsi://", 8)) {
strncpy(str, url + 8, MAX_STRING_SIZE);
}
portal = str;
user = getenv("LIBISCSI_CHAP_USERNAME");