From ce350e4314de7a06aaa401aaf42ff5f662092925 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 2 Mar 2011 19:57:01 +0000 Subject: [PATCH] [autoboot] Allow a SAN boot as a fallback if a filename boot returns 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 --- src/usr/autoboot.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index c743404c0..9a31279f9 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -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 ); @@ -171,12 +178,19 @@ 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 @@ -184,7 +198,10 @@ int uriboot ( struct uri *filename, struct uri *root_path ) { */ 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 ); @@ -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: @@ -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;