Skip to content

Commit

Permalink
[autoboot] Allow a SAN boot as a fallback if a filename boot returns
Browse files Browse the repository at this point in the history
Currently, if both a filename and root-path are present, iPXE will
hook the SAN device but will only attempt to boot from the filename.
Change this behaviour so that both are attempted.  Users who want to
avoid booting from the SAN as a fallback can do so via the existing
"skip-san-boot" setting.

This allows for seamless deployment to a SAN target using Windows
Deployment Services (and similar products).  A user simply has to
define the root-path option in DHCP and then use WDS to deploy the
system.  No further configuration should be required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 2, 2011
1 parent 8a61e37 commit ce350e4
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/usr/autoboot.c
Expand Up @@ -150,6 +150,13 @@ int uriboot ( struct uri *filename, struct uri *root_path ) {
root_path = NULL;
}

/* Check that we have something to boot */
if ( ! ( filename || root_path ) ) {
rc = -ENOENT_BOOT;
printf ( "Nothing to boot: %s\n", strerror ( rc ) );
goto err_no_boot;
}

/* Hook SAN device, if applicable */
if ( root_path ) {
drive = san_hook ( root_path, 0 );
Expand All @@ -171,20 +178,30 @@ int uriboot ( struct uri *filename, struct uri *root_path ) {
goto err_san_describe;
}

/* Attempt filename or SAN boot as applicable */
/* Allow a root-path-only boot with skip-san enabled to succeed */
rc = 0;

/* Attempt filename boot if applicable */
if ( filename ) {
if ( ( rc = imgdownload ( image, filename,
register_and_autoexec_image ) ) !=0){
printf ( "\nCould not chain image: %s\n",
strerror ( rc ) );
/* Fall through to (possibly) attempt a SAN boot
* as a fallback. If no SAN boot is attempted,
* our status will become the return status.
*/
} else {
/* Always print an extra newline, because we
* don't know where the NBP may have left the
* cursor.
*/
printf ( "\n" );
}
} else if ( root_path ) {
}

/* Attempt SAN boot if applicable */
if ( root_path ) {
if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
printf ( "Booting from SAN device %#02x\n", drive );
rc = san_boot ( drive );
Expand All @@ -193,11 +210,10 @@ int uriboot ( struct uri *filename, struct uri *root_path ) {
} else {
printf ( "Skipping boot from SAN device %#02x\n",
drive );
rc = 0;
/* Avoid overwriting a possible failure status
* from a filename boot.
*/
}
} else {
rc = -ENOENT_BOOT;
printf ( "Nothing to boot: %s\n", strerror ( rc ) );
}

err_san_describe:
Expand All @@ -212,6 +228,7 @@ int uriboot ( struct uri *filename, struct uri *root_path ) {
}
}
err_san_hook:
err_no_boot:
image_put ( image );
err_alloc_image:
return rc;
Expand Down

0 comments on commit ce350e4

Please sign in to comment.