Skip to content

Commit

Permalink
[autoboot] Connect SAN disk during a filename boot, if applicable
Browse files Browse the repository at this point in the history
For performing installations direct to a SAN target, it can be very
useful to hook a SAN disk and then proceed to perform a filename boot.
For example, the user may wish to hook the (empty) SAN installation
disk and then boot into the OS installer via TFTP.  This provides an
alternative mechanism to using "keep-san" and relying on the BIOS to
fall through to boot from the installation media, which is unreliable
on many BIOSes.

When a root-path is specified in addition to a boot filename, attempt
to hook the root-path as a SAN disk before booting from the specified
filename.  Since the root-path may be used for non-SAN purposes
(e.g. an NFS root mount point), ignore the root-path if it contains a
URI scheme that we do not support.

Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jan 27, 2011
1 parent 962cada commit e088892
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 159 deletions.
20 changes: 16 additions & 4 deletions src/hci/commands/sanboot_cmd.c
Expand Up @@ -18,9 +18,11 @@

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/uri.h>
#include <usr/autoboot.h>

FILE_LICENCE ( GPL2_OR_LATER );
Expand Down Expand Up @@ -52,23 +54,33 @@ static struct command_descriptor sanboot_cmd =
static int sanboot_exec ( int argc, char **argv ) {
struct sanboot_options opts;
const char *root_path;
struct uri *uri;
int rc;

/* Parse options */
if ( ( rc = parse_options ( argc, argv, &sanboot_cmd, &opts ) ) != 0 )
return rc;
goto err_parse_options;

/* Parse root path */
root_path = argv[optind];
uri = parse_uri ( root_path );
if ( ! uri ) {
rc = -ENOMEM;
goto err_parse_uri;
}

/* Boot from root path */
if ( ( rc = boot_root_path ( root_path ) ) != 0 ) {
if ( ( rc = uriboot ( NULL, uri ) ) != 0 ) {
printf ( "Could not boot from %s: %s\n",
root_path, strerror ( rc ) );
return rc;
goto err_uriboot;
}

return 0;
err_uriboot:
uri_put ( uri );
err_parse_uri:
err_parse_options:
return rc;
}

/** SAN commands */
Expand Down
1 change: 1 addition & 0 deletions src/include/ipxe/errfile.h
Expand Up @@ -235,6 +235,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ERRFILE_ifmgmt_cmd ( ERRFILE_OTHER | 0x001d0000 )
#define ERRFILE_fcmgmt_cmd ( ERRFILE_OTHER | 0x001e0000 )
#define ERRFILE_gdbstub_cmd ( ERRFILE_OTHER | 0x001f0000 )
#define ERRFILE_sanboot_cmd ( ERRFILE_OTHER | 0x00200000 )

/** @} */

Expand Down
8 changes: 5 additions & 3 deletions src/include/usr/autoboot.h
Expand Up @@ -11,12 +11,14 @@ FILE_LICENCE ( GPL2_OR_LATER );

#include <ipxe/in.h>
struct net_device;
struct uri;
struct settings;

extern int uriboot ( struct uri *filename, struct uri *root_path );
extern struct uri *
fetch_next_server_and_filename ( struct settings *settings );
extern int netboot ( struct net_device *netdev );
extern int autoboot ( void );
extern int boot_next_server_and_filename ( struct in_addr next_server,
const char *filename );
extern int boot_root_path ( const char *root_path );

extern int pxe_menu_boot ( struct net_device *netdev );

Expand Down
2 changes: 2 additions & 0 deletions src/include/usr/imgmgmt.h
Expand Up @@ -11,6 +11,8 @@ FILE_LICENCE ( GPL2_OR_LATER );

struct image;

extern int imgdownload ( struct image *image, struct uri *uri,
int ( * image_register ) ( struct image *image ) );
extern int imgfetch ( struct image *image, const char *uri_string,
int ( * image_register ) ( struct image *image ) );
extern int imgload ( struct image *image );
Expand Down

0 comments on commit e088892

Please sign in to comment.