From 3a598f085fcf60c6f5d171c19de5468eb2f48605 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 11 Mar 2010 19:22:27 +0000 Subject: [PATCH] -Fix iSCSI in xNBA 1.0.0 Former-commit-id: 8e5650a6b919c106759d702af507b8267fed613e --- gpxe/gpxe-1.0.0-registeriscsionpxe.patch | 126 +++++++++++++++++++++++ gpxe/xnba-kvm.spec | 4 +- gpxe/xnba-undi.spec | 4 +- 3 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 gpxe/gpxe-1.0.0-registeriscsionpxe.patch diff --git a/gpxe/gpxe-1.0.0-registeriscsionpxe.patch b/gpxe/gpxe-1.0.0-registeriscsionpxe.patch new file mode 100644 index 0000000..72da901 --- /dev/null +++ b/gpxe/gpxe-1.0.0-registeriscsionpxe.patch @@ -0,0 +1,126 @@ +diff -urN gpxe-1.0.0/src/arch/i386/interface/pcbios/iscsiboot.c gpxe-1.0.0-iscsireg/src/arch/i386/interface/pcbios/iscsiboot.c +--- gpxe-1.0.0/src/arch/i386/interface/pcbios/iscsiboot.c 2010-02-02 11:12:44.000000000 -0500 ++++ gpxe-1.0.0-iscsireg/src/arch/i386/interface/pcbios/iscsiboot.c 2010-03-11 14:19:05.000000000 -0500 +@@ -11,6 +11,56 @@ + + FILE_LICENCE ( GPL2_OR_LATER ); + ++static int iscsireg ( const char *root_path ) { ++ struct scsi_device *scsi; ++ struct int13_drive *drive; ++ int rc; ++ ++ scsi = zalloc ( sizeof ( *scsi ) ); ++ if ( ! scsi ) { ++ rc = -ENOMEM; ++ goto regerr_alloc_scsi; ++ } ++ drive = zalloc ( sizeof ( *drive ) ); ++ if ( ! drive ) { ++ rc = -ENOMEM; ++ goto regerr_alloc_drive; ++ } ++ ++ printf ( "Configuring iSCSI at %s\n", root_path ); ++ ++ if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) { ++ printf ( "Could not attach iSCSI device: %s\n", ++ strerror ( rc ) ); ++ goto regerr_attach; ++ } ++ if ( ( rc = init_scsidev ( scsi ) ) != 0 ) { ++ printf ( "Could not initialise iSCSI device: %s\n", ++ strerror ( rc ) ); ++ goto regerr_init; ++ } ++ ++ drive->blockdev = &scsi->blockdev; ++ ++ /* FIXME: ugly, ugly hack */ ++ struct net_device *netdev = last_opened_netdev(); ++ struct iscsi_session *iscsi = ++ container_of ( scsi->backend, struct iscsi_session, refcnt ); ++ ibft_fill_data ( netdev, iscsi ); ++ ++ register_int13_drive ( drive ); ++ printf ( "Registered as BIOS drive %#02x\n", drive->drive ); ++ return 0; ++ regerr_init: ++ iscsi_detach ( scsi ); ++ regerr_attach: ++ free ( drive ); ++ regerr_alloc_drive: ++ free ( scsi ); ++ regerr_alloc_scsi: ++ return rc; ++} ++ + static int iscsiboot ( const char *root_path ) { + struct scsi_device *scsi; + struct int13_drive *drive; +@@ -72,4 +122,5 @@ + struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = { + .prefix = "iscsi:", + .boot = iscsiboot, ++ .reg = iscsireg, + }; +diff -urN gpxe-1.0.0/src/include/gpxe/sanboot.h gpxe-1.0.0-iscsireg/src/include/gpxe/sanboot.h +--- gpxe-1.0.0/src/include/gpxe/sanboot.h 2010-02-02 11:12:44.000000000 -0500 ++++ gpxe-1.0.0-iscsireg/src/include/gpxe/sanboot.h 2010-03-11 14:19:05.000000000 -0500 +@@ -8,6 +8,7 @@ + struct sanboot_protocol { + const char *prefix; + int ( * boot ) ( const char *root_path ); ++ int ( * reg ) ( const char *root_path ); + }; + + #define SANBOOT_PROTOCOLS \ +diff -urN gpxe-1.0.0/src/usr/autoboot.c gpxe-1.0.0-iscsireg/src/usr/autoboot.c +--- gpxe-1.0.0/src/usr/autoboot.c 2010-02-02 11:12:44.000000000 -0500 ++++ gpxe-1.0.0-iscsireg/src/usr/autoboot.c 2010-03-11 14:19:36.000000000 -0500 +@@ -103,6 +103,25 @@ + } + + /** ++ * Register a drive in BIOS, but don't boot ++ * ++ * @v root_path Root path ++ * @ret rc Return status code ++ */ ++int reg_root_path ( const char *root_path ) { ++ struct sanboot_protocol *sanboot; ++ ++ /* Quick hack */ ++ for_each_table_entry ( sanboot, SANBOOT_PROTOCOLS ) { ++ if ( strncmp ( root_path, sanboot->prefix, ++ strlen ( sanboot->prefix ) ) == 0 ) { ++ return sanboot->reg ( root_path ); ++ } ++ } ++ ++ return -ENOTSUP; ++} ++/** + * Boot using root path + * + * @v root_path Root path +@@ -136,6 +155,7 @@ + struct setting pxe_boot_menu_setting + = { .tag = DHCP_PXE_BOOT_MENU }; + char buf[256]; ++ char ruf[256]; + struct in_addr next_server; + unsigned int pxe_discovery_control; + int rc; +@@ -167,6 +187,11 @@ + fetch_ipv4_setting ( NULL, &next_server_setting, &next_server ); + fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) ); + if ( buf[0] ) { ++ /* Going to PXE, but set up iBFT if applicable first */ ++ fetch_string_setting(NULL, &root_path_setting,ruf,sizeof(ruf)); ++ if (ruf[0]) { ++ reg_root_path ( ruf ); ++ } + printf ( "Booting from filename \"%s\"\n", buf ); + if ( ( rc = boot_next_server_and_filename ( next_server, + buf ) ) != 0 ) { diff --git a/gpxe/xnba-kvm.spec b/gpxe/xnba-kvm.spec index f5ece74..cf4836d 100644 --- a/gpxe/xnba-kvm.spec +++ b/gpxe/xnba-kvm.spec @@ -1,6 +1,6 @@ Name: xnba-kvm Version: 1.0.0 -Release: 2 +Release: 3 Summary: xNBA loader for virtual guests Obsoletes: etherboot-zroms-kvm Provides: etherboot-zroms-kvm @@ -21,7 +21,7 @@ ExclusiveArch: i386 x86_64 Source0: gpxe-%{version}.tar.bz2 Patch0: gpxe-0.9.7-branding.patch -Patch1: gpxe-0.9.9-registeriscsionpxe.patch +Patch1: gpxe-1.0.0-registeriscsionpxe.patch Patch2: gpxe-1.0.0-config.patch Patch3: gpxe-0.9.7-ignorepackets.patch Patch4: gpxe-0.9.7-kvmworkaround.patch diff --git a/gpxe/xnba-undi.spec b/gpxe/xnba-undi.spec index 540346b..8ebf26c 100644 --- a/gpxe/xnba-undi.spec +++ b/gpxe/xnba-undi.spec @@ -1,6 +1,6 @@ Name: xnba-undi Version: 1.0.0 -Release: 2 +Release: 3 Summary: xCAT Network Boot Agent for x86 PXE hosts Obsoletes: gpxe-undi @@ -17,7 +17,7 @@ BuildArch: noarch Source0: gpxe-%{version}.tar.bz2 Patch0: gpxe-0.9.7-branding.patch -Patch1: gpxe-0.9.9-registeriscsionpxe.patch +Patch1: gpxe-1.0.0-registeriscsionpxe.patch Patch2: gpxe-1.0.0-config.patch Patch3: gpxe-0.9.7-ignorepackets.patch Patch4: gpxe-0.9.7-kvmworkaround.patch