Patch 1 applies a small improvement to user experience, as suggested
by Matt DeVillier. Then patch 2 makes the switch.
Paolo Bonzini (2):
boot: delay exiting boot if menu key is ESC
boot: switch default menu key to ESC
--
2.3.0
>From e1d58cf75b466a4d84246b974cac63392a3ca1f4 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini
pbonzini@redhat.com
Date: Thu, 12 Mar 2015 15:30:12 +0100
Subject: [PATCH v3 1/2] boot.c: delay exiting boot if menu key is ESC
If the menu key is ESC, do not restart boot unless
1.5 seconds have passed. Otherwise users (trained by years of
repeatedly hitting keys to enter the BIOS) will end up hitting ESC
multiple times and immediately booting the primary boot device.
Suggested-by: Matt DeVillier
matt.devillier@gmail.com
Signed-off-by: Paolo Bonzini
pbonzini@redhat.com
---
src/boot.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/boot.c b/src/boot.c
index f23e9e1..3aab8d4 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -486,9 +486,15 @@ interactive_bootmenu(void)
, strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
}
- // Get key press
+ // Get key press. If the menu key is ESC, do not restart boot unless
+ // 1.5 seconds have passed. Otherwise users (trained by years of
+ // repeatedly hitting keys to enter the BIOS) will end up hitting ESC
+ // multiple times and immediately booting the primary boot device.
+ int esc_accepted_time = irqtimer_calc(menukey == 1 ? 1500 : 0);
for (;;) {
scan_code = get_keystroke(1000);
+ if (scan_code == 1 && !irqtimer_check(esc_accepted_time))
+ continue;
if (scan_code >= 1 && scan_code <= maxmenu+1)
break;
}
--
2.3.0
>From ece1e87f2eb89cc0d352d1e02454cb2bcb8da62e Mon Sep 17 00:00:00 2001
From: Paolo Bonzini
pbonzini@redhat.com
Date: Thu, 12 Mar 2015 15:31:17 +0100
Subject: [PATCH v3 2/2] boot: switch default menu key to ESC
On some platforms, F12 may be hard to access; for example, on OS X
machines F9-F12 have been intercepted by the OS for a long time, and
on newer OS X releases function keys are basically gone for good.
Which keys are and are not available depends on the client, not on
the server, but only function keys are usually trapped by terminals.
Hence, using ESC for the boot menu avoids the problems associated
with F12.
Suggested-by: Kevin O'Connor
kevin@koconnor.net
Signed-off-by: Paolo Bonzini
pbonzini@redhat.com
---
src/boot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/boot.c b/src/boot.c
index 3aab8d4..d6b1fb7 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -459,8 +459,8 @@ interactive_bootmenu(void)
;
char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL);
- int menukey = romfile_loadint("etc/boot-menu-key", 0x86);
- printf("%s", bootmsg ?: "\nPress F12 for boot menu.\n\n");
+ int menukey = romfile_loadint("etc/boot-menu-key", 1);
+ printf("%s", bootmsg ?: "\nPress ESC for boot menu.\n\n");
free(bootmsg);
u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT);
--
2.3.0