qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line
@ 2008-12-18 13:04 Jan Kiszka
  2008-12-18 13:30 ` Gleb Natapov
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jan Kiszka @ 2008-12-18 13:04 UTC (permalink / raw)
  To: qemu-devel

When booting a guest from the command line, you normally do not need the
interactive boot menu with its 3 s waiting that someone might press F12.
So this patch introduces a mechanism to enable the boot menu only on
demand, ie. when the user provided the command line switch -bootmenu.
This reduces boot times to their original dimension.

The host-guest interface used here is CMOS RAM byte 0x60. If it is
non-zero, the guest BIOS will skip the F12 delay, keeping the previous
behavior in case the host does not support it. -bootmenu was chosen in
favor of -boot as the syntax of the latter is not easily and cleanly
extensible.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 hw/pc.c                                       |    3 +++
 pc-bios/bios-pq/0006_optional-boot-menu.patch |   19 +++++++++++++++++++
 pc-bios/bios-pq/series                        |    1 +
 sysemu.h                                      |    1 +
 vl.c                                          |    9 +++++++++
 5 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/bios-pq/0006_optional-boot-menu.patch

diff --git a/hw/pc.c b/hw/pc.c
index 64c08a4..11576d1 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -348,6 +348,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
         }
     }
     rtc_set_memory(s, 0x39, val);
+
+    if (!bootmenu)
+        rtc_set_memory(s, 0x60, 1);
 }
 
 void ioport_set_a20(int enable)
diff --git a/pc-bios/bios-pq/0006_optional-boot-menu.patch b/pc-bios/bios-pq/0006_optional-boot-menu.patch
new file mode 100644
index 0000000..bbe5753
--- /dev/null
+++ b/pc-bios/bios-pq/0006_optional-boot-menu.patch
@@ -0,0 +1,19 @@
+Make interactive boot menu optional.
+
+Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
+
+diff --git a/bios/rombios.c b/bios/rombios.c
+index 123672f..7ce5b6c 100644
+--- a/bios/rombios.c
++++ b/bios/rombios.c
+@@ -2026,6 +2026,10 @@ interactive_bootkey()
+   Bit16u ss = get_SS();
+   Bit16u valid_choice = 0;
+ 
++  /* QEMU sets CMOS byte 0x60 to non-zero if the boot menu should be skipped */
++  if (inb_cmos(0x60))
++    return;
++
+   while (check_for_keystroke())
+     get_keystroke();
+ 
diff --git a/pc-bios/bios-pq/series b/pc-bios/bios-pq/series
index beff2c6..9c7b6a1 100644
--- a/pc-bios/bios-pq/series
+++ b/pc-bios/bios-pq/series
@@ -3,3 +3,4 @@
 0003_smp-startup-poll.patch
 0004_no-stack-protector.patch
 0005_hpet.patch
+0006_optional-boot-menu.patch
diff --git a/sysemu.h b/sysemu.h
index 94cffaf..1ecaed9 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -99,6 +99,7 @@ extern int semihosting_enabled;
 extern int old_param;
 extern const char *bootp_filename;
 extern DisplayState display_state;
+extern int bootmenu;
 
 #ifdef USE_KQEMU
 extern int kqemu_allowed;
diff --git a/vl.c b/vl.c
index 66dd975..fea9293 100644
--- a/vl.c
+++ b/vl.c
@@ -218,6 +218,7 @@ int no_quit = 0;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
 CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 #ifdef TARGET_I386
+int bootmenu = 0;
 int win2k_install_hack = 0;
 #endif
 int usb_enabled = 0;
@@ -3840,6 +3841,9 @@ static void help(int exitcode)
            "-sd file        use 'file' as SecureDigital card image\n"
            "-pflash file    use 'file' as a parallel flash image\n"
            "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
+#ifdef TARGET_I386
+           "-bootmenu       BIOS will display boot menu when pressing F12\n"
+#endif
            "-snapshot       write to temporary files instead of disk image files\n"
 #ifdef CONFIG_SDL
            "-no-frame       open SDL window without a frame and window decorations\n"
@@ -4018,6 +4022,7 @@ enum {
     QEMU_OPTION_boot,
     QEMU_OPTION_snapshot,
 #ifdef TARGET_I386
+    QEMU_OPTION_bootmenu,
     QEMU_OPTION_no_fd_bootchk,
 #endif
     QEMU_OPTION_m,
@@ -4114,6 +4119,7 @@ static const QEMUOption qemu_options[] = {
     { "boot", HAS_ARG, QEMU_OPTION_boot },
     { "snapshot", 0, QEMU_OPTION_snapshot },
 #ifdef TARGET_I386
+    { "bootmenu", 0, QEMU_OPTION_bootmenu },
     { "no-fd-bootchk", 0, QEMU_OPTION_no_fd_bootchk },
 #endif
     { "m", HAS_ARG, QEMU_OPTION_m },
@@ -4772,6 +4778,9 @@ int main(int argc, char **argv, char **envp)
                 drive_add(optarg, FD_ALIAS, popt->index - QEMU_OPTION_fda);
                 break;
 #ifdef TARGET_I386
+            case QEMU_OPTION_bootmenu:
+                bootmenu = 1;
+                break;
             case QEMU_OPTION_no_fd_bootchk:
                 fd_bootchk = 0;
                 break;

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-12-18 21:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-18 13:04 [Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line Jan Kiszka
2008-12-18 13:30 ` Gleb Natapov
2008-12-18 16:06   ` [Qemu-devel] " Jan Kiszka
2008-12-18 16:20 ` [Qemu-devel] " Paul Brook
2008-12-18 16:28   ` Anthony Liguori
2008-12-18 16:57     ` Jan Kiszka
2008-12-18 17:23       ` Anthony Liguori
2008-12-18 17:41         ` Gleb Natapov
2008-12-18 18:43           ` Laurent Vivier
2008-12-18 21:28             ` [Qemu-devel] " Jan Kiszka
2008-12-18 16:27 ` [Qemu-devel] " Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).