Parcourir la source

[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 <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 13 ans
Parent
révision
ce350e4314
1 fichiers modifiés avec 23 ajouts et 6 suppressions
  1. 23
    6
      src/usr/autoboot.c

+ 23
- 6
src/usr/autoboot.c Voir le fichier

150
 		root_path = NULL;
150
 		root_path = NULL;
151
 	}
151
 	}
152
 
152
 
153
+	/* Check that we have something to boot */
154
+	if ( ! ( filename || root_path ) ) {
155
+		rc = -ENOENT_BOOT;
156
+		printf ( "Nothing to boot: %s\n", strerror ( rc ) );
157
+		goto err_no_boot;
158
+	}
159
+
153
 	/* Hook SAN device, if applicable */
160
 	/* Hook SAN device, if applicable */
154
 	if ( root_path ) {
161
 	if ( root_path ) {
155
 		drive = san_hook ( root_path, 0 );
162
 		drive = san_hook ( root_path, 0 );
171
 		goto err_san_describe;
178
 		goto err_san_describe;
172
 	}
179
 	}
173
 
180
 
174
-	/* Attempt filename or SAN boot as applicable */
181
+	/* Allow a root-path-only boot with skip-san enabled to succeed */
182
+	rc = 0;
183
+
184
+	/* Attempt filename boot if applicable */
175
 	if ( filename ) {
185
 	if ( filename ) {
176
 		if ( ( rc = imgdownload ( image, filename,
186
 		if ( ( rc = imgdownload ( image, filename,
177
 					  register_and_autoexec_image ) ) !=0){
187
 					  register_and_autoexec_image ) ) !=0){
178
 			printf ( "\nCould not chain image: %s\n",
188
 			printf ( "\nCould not chain image: %s\n",
179
 				 strerror ( rc ) );
189
 				 strerror ( rc ) );
190
+			/* Fall through to (possibly) attempt a SAN boot
191
+			 * as a fallback.  If no SAN boot is attempted,
192
+			 * our status will become the return status.
193
+			 */
180
 		} else {
194
 		} else {
181
 			/* Always print an extra newline, because we
195
 			/* Always print an extra newline, because we
182
 			 * don't know where the NBP may have left the
196
 			 * don't know where the NBP may have left the
184
 			 */
198
 			 */
185
 			printf ( "\n" );
199
 			printf ( "\n" );
186
 		}
200
 		}
187
-	} else if ( root_path ) {
201
+	}
202
+
203
+	/* Attempt SAN boot if applicable */
204
+	if ( root_path ) {
188
 		if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
205
 		if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
189
 			printf ( "Booting from SAN device %#02x\n", drive );
206
 			printf ( "Booting from SAN device %#02x\n", drive );
190
 			rc = san_boot ( drive );
207
 			rc = san_boot ( drive );
193
 		} else {
210
 		} else {
194
 			printf ( "Skipping boot from SAN device %#02x\n",
211
 			printf ( "Skipping boot from SAN device %#02x\n",
195
 				 drive );
212
 				 drive );
196
-			rc = 0;
213
+			/* Avoid overwriting a possible failure status
214
+			 * from a filename boot.
215
+			 */
197
 		}
216
 		}
198
-	} else {
199
-		rc = -ENOENT_BOOT;
200
-		printf ( "Nothing to boot: %s\n", strerror ( rc ) );
201
 	}
217
 	}
202
 
218
 
203
  err_san_describe:
219
  err_san_describe:
212
 		}
228
 		}
213
 	}
229
 	}
214
  err_san_hook:
230
  err_san_hook:
231
+ err_no_boot:
215
 	image_put ( image );
232
 	image_put ( image );
216
  err_alloc_image:
233
  err_alloc_image:
217
 	return rc;
234
 	return rc;

Chargement…
Annuler
Enregistrer