Browse Source

[autoboot] Enable infrastructure to specify an autoboot device location

iPXE will currently attempt to boot from every network device for
which it has a driver.  Where a system has more than one network
device supported by iPXE, this renders BIOS IPL lists ineffective.

Allow an autoboot device location to be specified.  If such a location
is specified, then only devices matching that location will be used as
part of the automatic boot sequence.  If no such location is
specified, then all devices will be used.

Note that this does not affect the "autoboot" command, which will
continue to use all devices.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Alex Williamson 10 years ago
parent
commit
123bae9d93
2 changed files with 29 additions and 18 deletions
  1. 3
    1
      src/include/usr/autoboot.h
  2. 26
    17
      src/usr/autoboot.c

+ 3
- 1
src/include/usr/autoboot.h View File

@@ -10,6 +10,7 @@
10 10
 FILE_LICENCE ( GPL2_OR_LATER );
11 11
 
12 12
 #include <ipxe/in.h>
13
+#include <ipxe/device.h>
13 14
 struct net_device;
14 15
 struct uri;
15 16
 struct settings;
@@ -25,12 +26,13 @@ enum uriboot_flags {
25 26
 			 URIBOOT_NO_SAN_BOOT |	   \
26 27
 			 URIBOOT_NO_SAN_UNHOOK )
27 28
 
29
+extern struct device_description autoboot_device;
30
+
28 31
 extern int uriboot ( struct uri *filename, struct uri *root_path, int drive,
29 32
 		     unsigned int flags );
30 33
 extern struct uri *
31 34
 fetch_next_server_and_filename ( struct settings *settings );
32 35
 extern int netboot ( struct net_device *netdev );
33
-extern int autoboot ( void );
34 36
 extern void ipxe ( struct net_device *netdev );
35 37
 
36 38
 extern int pxe_menu_boot ( struct net_device *netdev );

+ 26
- 17
src/usr/autoboot.c View File

@@ -49,6 +49,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
49 49
  *
50 50
  */
51 51
 
52
+/** Device location of preferred autoboot device */
53
+struct device_description autoboot_device;
54
+
52 55
 /* Disambiguate the various error causes */
53 56
 #define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT )
54 57
 #define EINFO_ENOENT_BOOT \
@@ -73,15 +76,6 @@ __weak int pxe_menu_boot ( struct net_device *netdev __unused ) {
73 76
 	return -ENOTSUP;
74 77
 }
75 78
 
76
-/**
77
- * Identify the boot network device
78
- *
79
- * @ret netdev		Boot network device
80
- */
81
-static struct net_device * find_boot_netdev ( void ) {
82
-	return NULL;
83
-}
84
-
85 79
 /**
86 80
  * Parse next-server and filename into a URI
87 81
  *
@@ -427,22 +421,37 @@ int netboot ( struct net_device *netdev ) {
427 421
 	return rc;
428 422
 }
429 423
 
424
+/**
425
+ * Test if network device matches the autoboot device location
426
+ *
427
+ * @v netdev		Network device
428
+ * @ret is_autoboot	Network device matches the autoboot device location
429
+ */
430
+static int is_autoboot_device ( struct net_device *netdev ) {
431
+
432
+	return ( ( netdev->dev->desc.bus_type == autoboot_device.bus_type ) &&
433
+		 ( netdev->dev->desc.location == autoboot_device.location ) );
434
+}
435
+
430 436
 /**
431 437
  * Boot the system
432 438
  */
433
-int autoboot ( void ) {
434
-	struct net_device *boot_netdev;
439
+static int autoboot ( void ) {
435 440
 	struct net_device *netdev;
436 441
 	int rc = -ENODEV;
437 442
 
438
-	/* If we have an identifable boot device, try that first */
439
-	if ( ( boot_netdev = find_boot_netdev() ) )
440
-		rc = netboot ( boot_netdev );
441
-
442
-	/* If that fails, try booting from any of the other devices */
443
+	/* Try booting from each network device.  If we have a
444
+	 * specified autoboot device location, then use only devices
445
+	 * matching that location.
446
+	 */
443 447
 	for_each_netdev ( netdev ) {
444
-		if ( netdev == boot_netdev )
448
+
449
+		/* Skip any non-matching devices, if applicable */
450
+		if ( autoboot_device.bus_type &&
451
+		     ( ! is_autoboot_device ( netdev ) ) )
445 452
 			continue;
453
+
454
+		/* Attempt booting from this device */
446 455
 		rc = netboot ( netdev );
447 456
 	}
448 457
 

Loading…
Cancel
Save