Просмотр исходного кода

[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 11 лет назад
Родитель
Сommit
123bae9d93
2 измененных файлов: 29 добавлений и 18 удалений
  1. 3
    1
      src/include/usr/autoboot.h
  2. 26
    17
      src/usr/autoboot.c

+ 3
- 1
src/include/usr/autoboot.h Просмотреть файл

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

+ 26
- 17
src/usr/autoboot.c Просмотреть файл

49
  *
49
  *
50
  */
50
  */
51
 
51
 
52
+/** Device location of preferred autoboot device */
53
+struct device_description autoboot_device;
54
+
52
 /* Disambiguate the various error causes */
55
 /* Disambiguate the various error causes */
53
 #define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT )
56
 #define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT )
54
 #define EINFO_ENOENT_BOOT \
57
 #define EINFO_ENOENT_BOOT \
73
 	return -ENOTSUP;
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
  * Parse next-server and filename into a URI
80
  * Parse next-server and filename into a URI
87
  *
81
  *
427
 	return rc;
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
  * Boot the system
437
  * Boot the system
432
  */
438
  */
433
-int autoboot ( void ) {
434
-	struct net_device *boot_netdev;
439
+static int autoboot ( void ) {
435
 	struct net_device *netdev;
440
 	struct net_device *netdev;
436
 	int rc = -ENODEV;
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
 	for_each_netdev ( netdev ) {
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
 			continue;
452
 			continue;
453
+
454
+		/* Attempt booting from this device */
446
 		rc = netboot ( netdev );
455
 		rc = netboot ( netdev );
447
 	}
456
 	}
448
 
457
 

Загрузка…
Отмена
Сохранить