[sanboot] Extend the "keep-san" option to non-iSCSI SAN protocols
authorMichael Brown <mcb30@etherboot.org>
Wed, 4 Nov 2009 01:18:08 +0000 (01:18 +0000)
committerMichael Brown <mcb30@etherboot.org>
Wed, 4 Nov 2009 01:21:43 +0000 (01:21 +0000)
This disgustingly ugly hack just keeps getting worse.

src/arch/i386/interface/pcbios/aoeboot.c
src/arch/i386/interface/pcbios/ib_srpboot.c
src/arch/i386/interface/pcbios/iscsiboot.c
src/arch/i386/interface/pcbios/keepsan.c [new file with mode: 0644]
src/include/gpxe/sanboot.h

index 46484c0..fcab42b 100644 (file)
@@ -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 );
 
index 5b9c2c9..b1cbc33 100644 (file)
@@ -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 );
 
index f200c16..d8bb55a 100644 (file)
@@ -4,28 +4,16 @@
 #include <stdio.h>
 #include <errno.h>
 #include <gpxe/iscsi.h>
-#include <gpxe/settings.h>
-#include <gpxe/dhcp.h>
 #include <gpxe/netdevice.h>
 #include <gpxe/ibft.h>
-#include <gpxe/init.h>
 #include <gpxe/sanboot.h>
 #include <int13.h>
-#include <usr/autoboot.h>
 
 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 (file)
index 0000000..904e017
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <gpxe/settings.h>
+#include <gpxe/dhcp.h>
+#include <gpxe/init.h>
+#include <gpxe/sanboot.h>
+#include <usr/autoboot.h>
+
+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;
+}
index 6ec2ec2..fd06316 100644 (file)
@@ -15,4 +15,6 @@ struct sanboot_protocol {
 
 #define __sanboot_protocol __table_entry ( SANBOOT_PROTOCOLS, 01 )
 
+extern int keep_san ( void );
+
 #endif /* _GPXE_SANBOOT_H */