All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line
Date: Thu, 18 Dec 2008 14:04:21 +0100	[thread overview]
Message-ID: <494A4A55.2090700@siemens.com> (raw)

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;

             reply	other threads:[~2008-12-18 13:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 13:04 Jan Kiszka [this message]
2008-12-18 13:30 ` [Qemu-devel] [PATCH] x86: Manage BIOS boot menu via command line 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=494A4A55.2090700@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.