From be670840c75165fd290da33a6245f013346b6c6f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 4 Nov 2009 01:18:08 +0000 Subject: [PATCH] [sanboot] Extend the "keep-san" option to non-iSCSI SAN protocols This disgustingly ugly hack just keeps getting worse. --- src/arch/i386/interface/pcbios/aoeboot.c | 4 ++++ src/arch/i386/interface/pcbios/ib_srpboot.c | 4 ++++ src/arch/i386/interface/pcbios/iscsiboot.c | 18 +------------- src/arch/i386/interface/pcbios/keepsan.c | 26 +++++++++++++++++++++ src/include/gpxe/sanboot.h | 2 ++ 5 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 src/arch/i386/interface/pcbios/keepsan.c diff --git a/src/arch/i386/interface/pcbios/aoeboot.c b/src/arch/i386/interface/pcbios/aoeboot.c index 46484c00..fcab42b0 100644 --- a/src/arch/i386/interface/pcbios/aoeboot.c +++ b/src/arch/i386/interface/pcbios/aoeboot.c @@ -49,6 +49,10 @@ static int aoeboot ( const char *root_path ) { rc = int13_boot ( drive.drive ); printf ( "Boot failed\n" ); + /* Leave drive registered, if instructed to do so */ + if ( keep_san() ) + return rc; + printf ( "Unregistering BIOS drive %#02x\n", drive.drive ); unregister_int13_drive ( &drive ); diff --git a/src/arch/i386/interface/pcbios/ib_srpboot.c b/src/arch/i386/interface/pcbios/ib_srpboot.c index 5b9c2c9a..b1cbc337 100644 --- a/src/arch/i386/interface/pcbios/ib_srpboot.c +++ b/src/arch/i386/interface/pcbios/ib_srpboot.c @@ -50,6 +50,10 @@ static int ib_srpboot ( const char *root_path ) { rc = int13_boot ( drive->drive ); printf ( "Boot failed\n" ); + /* Leave drive registered, if instructed to do so */ + if ( keep_san() ) + return rc; + printf ( "Unregistering BIOS drive %#02x\n", drive->drive ); unregister_int13_drive ( drive ); diff --git a/src/arch/i386/interface/pcbios/iscsiboot.c b/src/arch/i386/interface/pcbios/iscsiboot.c index f200c16f..d8bb55a2 100644 --- a/src/arch/i386/interface/pcbios/iscsiboot.c +++ b/src/arch/i386/interface/pcbios/iscsiboot.c @@ -4,28 +4,16 @@ #include #include #include -#include -#include #include #include -#include #include #include -#include FILE_LICENCE ( GPL2_OR_LATER ); -struct setting keep_san_setting __setting = { - .name = "keep-san", - .description = "Preserve SAN connection", - .tag = DHCP_EB_KEEP_SAN, - .type = &setting_type_int8, -}; - static int iscsiboot ( const char *root_path ) { struct scsi_device *scsi; struct int13_drive *drive; - int keep_san; int rc; scsi = zalloc ( sizeof ( *scsi ) ); @@ -67,12 +55,8 @@ static int iscsiboot ( const char *root_path ) { printf ( "Boot failed\n" ); /* Leave drive registered, if instructed to do so */ - keep_san = fetch_intz_setting ( NULL, &keep_san_setting ); - if ( keep_san ) { - printf ( "Preserving connection to SAN disk\n" ); - shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES; + if ( keep_san() ) return rc; - } printf ( "Unregistering BIOS drive %#02x\n", drive->drive ); unregister_int13_drive ( drive ); diff --git a/src/arch/i386/interface/pcbios/keepsan.c b/src/arch/i386/interface/pcbios/keepsan.c new file mode 100644 index 00000000..904e017d --- /dev/null +++ b/src/arch/i386/interface/pcbios/keepsan.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include + +struct setting keep_san_setting __setting = { + .name = "keep-san", + .description = "Preserve SAN connection", + .tag = DHCP_EB_KEEP_SAN, + .type = &setting_type_int8, +}; + +int keep_san ( void ) { + int keep_san; + + keep_san = fetch_intz_setting ( NULL, &keep_san_setting ); + if ( ! keep_san ) + return 0; + + printf ( "Preserving connection to SAN disk\n" ); + shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES; + return 1; +} diff --git a/src/include/gpxe/sanboot.h b/src/include/gpxe/sanboot.h index 6ec2ec24..fd063164 100644 --- a/src/include/gpxe/sanboot.h +++ b/src/include/gpxe/sanboot.h @@ -15,4 +15,6 @@ struct sanboot_protocol { #define __sanboot_protocol __table_entry ( SANBOOT_PROTOCOLS, 01 ) +extern int keep_san ( void ); + #endif /* _GPXE_SANBOOT_H */