aboutsummaryrefslogtreecommitdiff
path: root/src/hci
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2017-03-26 15:12:11 +0300
committerMichael Brown <mcb30@ipxe.org>2017-03-26 16:06:02 +0300
commitbb5a54b79a414082d0b39d478a8b3332c56d68e5 (patch)
treec022d5b8ed56be56414eb007273aeacd57c44d37 /src/hci
parentc212597336fd055de854043b83425cbdf1f42603 (diff)
downloadipxe-bb5a54b79a414082d0b39d478a8b3332c56d68e5.zip
ipxe-bb5a54b79a414082d0b39d478a8b3332c56d68e5.tar.gz
ipxe-bb5a54b79a414082d0b39d478a8b3332c56d68e5.tar.bz2
[block] Add basic multipath support
Add basic support for multipath block devices. The "sanboot" and "sanhook" commands now accept a list of SAN URIs. We open all URIs concurrently. The first connection to become available for issuing block device commands is marked as the active path and used for all subsequent commands; all other connections are then closed. Whenever the active path fails, we reopen all URIs and repeat the process. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r--src/hci/commands/sanboot_cmd.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c
index 24ec8bc..9965ec1 100644
--- a/src/hci/commands/sanboot_cmd.c
+++ b/src/hci/commands/sanboot_cmd.c
@@ -71,12 +71,12 @@ static union {
/** "sanhook" command descriptor */
static struct command_descriptor sanhook_cmd =
- COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, 1,
+ COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, MAX_ARGUMENTS,
"<root-path>" );
/** "sanboot" command descriptor */
static struct command_descriptor sanboot_cmd =
- COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, 1,
+ COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, MAX_ARGUMENTS,
"[<root-path>]" );
/** "sanunhook" command descriptor */
@@ -96,9 +96,10 @@ static int sanboot_core_exec ( int argc, char **argv,
struct command_descriptor *cmd,
int default_flags, int no_root_path_flags ) {
struct sanboot_options opts;
- const char *root_path;
- struct uri *uri;
+ struct uri *uris[argc];
+ int count;
int flags;
+ int i;
int rc;
/* Initialise options */
@@ -109,17 +110,14 @@ static int sanboot_core_exec ( int argc, char **argv,
if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 )
goto err_parse_options;
- /* Parse root path, if present */
- if ( argc > optind ) {
- root_path = argv[optind];
- uri = parse_uri ( root_path );
- if ( ! uri ) {
+ /* Parse root paths, if present */
+ count = ( argc - optind );
+ for ( i = 0 ; i < count ; i++ ) {
+ uris[i] = parse_uri ( argv[ optind + i ] );
+ if ( ! uris[i] ) {
rc = -ENOMEM;
goto err_parse_uri;
}
- } else {
- root_path = NULL;
- uri = NULL;
}
/* Construct flags */
@@ -128,16 +126,18 @@ static int sanboot_core_exec ( int argc, char **argv,
flags |= URIBOOT_NO_SAN_DESCRIBE;
if ( opts.keep )
flags |= URIBOOT_NO_SAN_UNHOOK;
- if ( ! root_path )
+ if ( ! count )
flags |= no_root_path_flags;
/* Boot from root path */
- if ( ( rc = uriboot ( NULL, uri, opts.drive, flags ) ) != 0 )
+ if ( ( rc = uriboot ( NULL, uris, count, opts.drive, flags ) ) != 0 )
goto err_uriboot;
err_uriboot:
- uri_put ( uri );
+ i = count;
err_parse_uri:
+ for ( i-- ; i >= 0 ; i-- )
+ uri_put ( uris[i] );
err_parse_options:
return rc;
}