qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line
Date: Thu, 18 Dec 2008 14:04:21 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

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 <address@hidden>
---

 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 <address@hidden>
+
+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;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]