This patch adds a shortcut for network boot, similar to what is present on bare-metal machines. F11 will prioritize BCV/BEV entries for network devices over all the other items of the boot list.
Signed-off-by: Paolo Bonzini pbonzini@redhat.com --- src/boot.c | 36 +++++++++++++++++++++++++++++++----- 1 file modificato, 31 inserzioni(+), 5 rimozioni(-)
diff --git a/src/boot.c b/src/boot.c index c136ad4..682f239 100644 --- a/src/boot.c +++ b/src/boot.c @@ -292,6 +292,7 @@ static struct bootentry_s *BootList; #define IPL_TYPE_BEV 0x50 #define IPL_TYPE_BCV 0x60 #define IPL_TYPE_MASK 0xF0 +#define IPL_TYPE_CLASS 0x0F
static void bootentry_add(int type, int prio, u32 data, const char *desc) @@ -406,26 +407,51 @@ interactive_bootmenu(void) while (get_keystroke(0) >= 0) ;
- printf("Press F12 for boot menu.\n\n"); + wait_threads(); + struct bootentry_s *pos; + for (pos = BootList; pos; pos = pos->next) { + if ((pos->type & IPL_TYPE_CLASS) == PCI_BASE_CLASS_NETWORK) + break; + } + + printf("Press %sF12 for boot menu.\n\n" + , pos ? "F11 for network boot, or " : "");
u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT); enable_bootsplash(); int scan_code = get_keystroke(menutime); disable_bootsplash(); switch (scan_code) { + case 0x85: { // F11 + // Prioritize BEV/BCV entries + if (!pos) + return; + + struct bootentry_s **pprev = &BootList, **pprev_new = &BootList; + while ((pos = *pprev) != NULL) { + if ((pos->type & IPL_TYPE_CLASS) == PCI_BASE_CLASS_NETWORK) { + *pprev = pos->next; + pos->next = *pprev_new; + *pprev_new = pos; + pos->priority = 0; + pprev_new = &pos->next; + } else { + pprev = &pos->next; + } + } + break; + } + case 0x86: { // F12 printf("Select boot device:\n\n"); - wait_threads();
// Show menu items - struct bootentry_s *pos = BootList; int maxmenu = 0; - while (pos) { + for (pos = BootList; pos; pos = pos->next) { char desc[60]; maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc))); - pos = pos->next; }
// Get key press