[gPXE-devel] supporting gpxe sanboot (ie. attach) without boot

Sven-Thorsten Dietrich sdietrich at novell.com
Wed May 19 12:25:45 EDT 2010


On Wed, 2010-05-19 at 11:50 -0400, Joshua Oreman wrote:
> On Wed, May 19, 2010 at 8:33 AM,  <cruejones at comcast.net> wrote:
> > Hi,
> >
> > I'm starting this thread to help continue the discussion around implementing an option
> > allowing gpxe to attach to ISCSI targets in a persistent manner without booting from them.
> > So far we have developed a patch that implements a "keep-san-nb" (keep san no boot) option.
> > While this patch works it might make sense to change the "sanboot" directive to something more generic
> > like "sanmount" then provide a boot option like "sanboot". This avoids the confusion around the "sanboot"
> > option name directly implying booting.
> >
> > Any thoughts?
> 
> I'm working on a rather large branch called "unity" that unifies
> treatment of images and SAN disks. That is, the "sanboot" command
> becomes effectively an alias for "chain"; `fetching' a SAN `image'
> connects to the SAN device and proxies reads and writes to it
> appropriately. It also provides an "attach" command (analogous to your
> "sanmount") for making any image (memory or SAN) available using the
> typical int 13h mechanism. (Among other things, this allows booting
> from an ISO image over iSCSI, if the OS supports it. I've successfully
> demonstrated this with a slightly modified Ubuntu livecd.)
> 
> It's been a few months since I've been able to work on this in
> earnest, and it still needs some cleaning up, but I'd expect a patch
> to hit the mailing list within a month or so.
> 
> If you'd like to send your patch, that'd be great so other people can
> benefit now, but my hope is that the unity branch will be merged once
> it's cleaned up and will provide a more generic solution here.
> 

No need to duplicate your effort, I assume we can hold out and update
our code later. The attached the patch for the mean time addresses the
issue - as noted its merely a POC.

Sven

> -- Josh
> 
> >
> > Thanks
> > _______________________________________________
> > gPXE-devel mailing list
> > gPXE-devel at etherboot.org
> > http://etherboot.org/mailman/listinfo/gpxe-devel
> >

Implement keep_san_nb setting extending keep_san while also suppressing boot.

This is at this point just POC code to enable mounting san without booting.

Pls refer to related discussion on gpxe-devel at etherboot.org.

Signed-off-by: Sven-Thorsten Dietrich <thebigcorporation at gmail.com>

diff --git a/src/arch/i386/interface/pcbios/iscsiboot.c b/src/arch/i386/interface/pcbios/iscsiboot.c
index 00efd8f..d15f93b 100644
--- a/src/arch/i386/interface/pcbios/iscsiboot.c
+++ b/src/arch/i386/interface/pcbios/iscsiboot.c
@@ -48,12 +48,19 @@ static int iscsiboot ( const char *root_path ) {
 
 	register_int13_drive ( drive );
 	printf ( "Registered as BIOS drive %#02x\n", drive->drive );
-	printf ( "Booting from BIOS drive %#02x\n", drive->drive );
-	rc = int13_boot ( drive->drive );
-	printf ( "Boot failed\n" );
+
+	if (keep_san_nb()) {
+		printf ( "NOT Booting from BIOS drive %#02x\n", drive->drive );
+		rc = 0;
+	} 
+	else {
+		printf ( "Booting from BIOS drive %#02x\n", drive->drive );
+		rc = int13_boot ( drive->drive );
+		printf ( "Boot failed\n" );
+	}
 
 	/* Leave drive registered, if instructed to do so */
-	if ( keep_san() )
+	if ( keep_san() || keep_san_nb())
 		return rc;
 
 	printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
diff --git a/src/arch/i386/interface/pcbios/keepsan_nb.c b/src/arch/i386/interface/pcbios/keepsan_nb.c
new file mode 100644
index 0000000..a8676b5
--- /dev/null
+++ b/src/arch/i386/interface/pcbios/keepsan_nb.c
@@ -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_nb_setting __setting = {
+	.name = "keep-san-nb",
+	.description = "Preserve SAN connection - Nonboot",
+	.tag = DHCP_EB_KEEP_SAN_NB,
+	.type = &setting_type_int8,
+};
+
+int keep_san_nb ( void ) {
+	int keep_san_nb;
+
+	keep_san_nb = fetch_intz_setting ( NULL, &keep_san_nb_setting );
+	if ( ! keep_san_nb )
+		return 0;
+
+	printf ( "Preserving connection to SAN disk - nonboot\n" );
+	shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
+	return 1;
+}
diff --git a/src/include/gpxe/dhcp.h b/src/include/gpxe/dhcp.h
index ebfe8ed..9987a51 100644
--- a/src/include/gpxe/dhcp.h
+++ b/src/include/gpxe/dhcp.h
@@ -298,6 +298,15 @@ struct dhcp_client_uuid {
  */
 #define DHCP_EB_KEEP_SAN DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x08 )
 
+/** Keep SAN drive registered - NONBOOT
+ *
+ * If set to a non-zero value, gPXE will not detach any SAN drive
+ * and skips booting from it.  (This option is required in order
+ * to perform a Solaris installation direct to an iSCSI
+ * target.)
+ */
+#define DHCP_EB_KEEP_SAN_NB DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x09 )
+
 /*
  * Tags in the range 0x10-0x7f are reserved for feature markers
  *
diff --git a/src/include/gpxe/sanboot.h b/src/include/gpxe/sanboot.h
index fd06316..e301ac0 100644
--- a/src/include/gpxe/sanboot.h
+++ b/src/include/gpxe/sanboot.h
@@ -16,5 +16,6 @@ struct sanboot_protocol {
 #define __sanboot_protocol __table_entry ( SANBOOT_PROTOCOLS, 01 )
 
 extern int keep_san ( void );
+extern int keep_san_nb ( void );
 
 #endif /* _GPXE_SANBOOT_H */




More information about the gPXE-devel mailing list