Skip to contentSkip to conversation

RFC: Add a new boot parameter to set delay time before seabios retry to boot

Qemu-devel Superseded Amos Kong 5 participants 11 messages Sep 6, 2012 – Sep 20, 2012

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

Hi all,

Seabios supports automatically reboot after X second delay on failed boot [1], I want to add a parameter for qemu, it's used put a boot parameter into romfile for seabios to set the delay time.

# qemu ... -boot order=n,menu=on,delay=5 ...

Comments & suggestions ? Thanks!

[1] commit b8fcf46826e77c835da0ad8127a17895bb2e2fca

Author: Kevin O'Connor <[email protected]>
Date:   Sat May 12 22:12:22 2012 -0400

Automatically reboot after 60 second delay on failed boot.

If no valid boot devices are found, display the error for 60 seconds (by default) and then reboot. This enables a periodic retry in case one of the boot devices is still coming online.

Signature · 1 line
			Amos.
#1 lore raw
Quoted 8 lines · Amos Kong

Hi all,

Seabios supports automatically reboot after X second delay on failed boot [1],
I want to add a parameter for qemu, it's used put a boot parameter into romfile
for seabios to set the delay time.

Quoted 5 lines
# qemu ... -boot order=n,menu=on,delay=5 ...

Comments & suggestions ? Thanks!

It is not cleat what "delay" mean. May be call it "reboot-timeout".

Quoted 5 lines

[1] commit b8fcf46826e77c835da0ad8127a17895bb2e2fca

Author: Kevin O'Connor <[email protected]>
Date:   Sat May 12 22:12:22 2012 -0400
Quoted 12 lines

Automatically reboot after 60 second delay on failed boot.

If no valid boot devices are found, display the error for 60 seconds (by default) and then reboot. This enables a periodic retry in case one of the boot devices is still coming online.

Signature · 1 line
			Amos.

--
Gleb.

author
#2 lore raw

PATCH 1/1 add a boot parameter to set reboot timeout

In reply to Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. This feature need the new seabios's support.

---
 hw/fw_cfg.c     |   29 +++++++++++++++++++++++++++++
 qemu-config.c   |    3 +++
 qemu-options.hx |   10 +++++++---
 vl.c            |    3 ++-
 4 files changed, 41 insertions(+), 4 deletions(-)
hw/fw_cfg.c +29 -0
index 7b3b576..a017184 100644
@@ -183,6 +183,34 @@ static void fw_cfg_bootsplash(FWCfgState *s)
     }
 }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    if (reboot_timeout >= 0) {
+        /* validate the input */
+        if (reboot_timeout > 0xffff) {
+            error_report("reboot timeout is larger than 65535,"
+                         " force it to 65535.");
+            reboot_timeout = 0xffff;
+        }
+       fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4),
+                       4);
+    }
+}
+
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
 {
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +525,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
     fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
     s->machine_ready.notify = fw_cfg_machine_ready;
     qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
         }, {
             .name = "splash-time",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
         },
         { /*End of list */ }
     },
qemu-options.hx +7 -3
index 3c411c4..d50505b 100644
@@ -339,13 +339,14 @@ ETEXI
 
 DEF("boot", HAS_ARG, QEMU_OPTION_boot,
     "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
     "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
     "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
     QEMU_ARCH_ALL)
 STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
 @findex -boot
 Specify boot order @var{drives} as a string of drive letters. Valid
 drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,9 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
 format(true color). The resolution should be supported by the SVGA mode, so
 the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot.
+
 @example
 # try to boot from network first, then from hard disk
 qemu-system-i386 -boot order=nc
vl.c +2 -1
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                 {
                     static const char * const params[] = {
                         "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                     };
                     char buf[sizeof(boot_devices)];
                     char *standard_boot_devices;
Signature · 1 line
1.7.1
#3 lore raw

Re: [Qemu-devel] [PATCH] add a boot parameter to set reboot timeout

Quoted 9 lines · Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. This feature need the new seabios's support.

IMO default should be no reboot just like before Seabios change.

Quoted 117 lines
---
 hw/fw_cfg.c     |   29 +++++++++++++++++++++++++++++
 qemu-config.c   |    3 +++
 qemu-options.hx |   10 +++++++---
 vl.c            |    3 ++-
 4 files changed, 41 insertions(+), 4 deletions(-)
hw/fw_cfg.c +29 -0
index 7b3b576..a017184 100644
@@ -183,6 +183,34 @@ static void fw_cfg_bootsplash(FWCfgState *s)
     }
 }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    if (reboot_timeout >= 0) {
+        /* validate the input */
+        if (reboot_timeout > 0xffff) {
+            error_report("reboot timeout is larger than 65535,"
+                         " force it to 65535.");
+            reboot_timeout = 0xffff;
+        }
+       fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4),
+                       4);
+    }
+}
+
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
 {
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +525,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
     fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
     s->machine_ready.notify = fw_cfg_machine_ready;
     qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
         }, {
             .name = "splash-time",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
         },
         { /*End of list */ }
     },
qemu-options.hx +7 -3
index 3c411c4..d50505b 100644
@@ -339,13 +339,14 @@ ETEXI
 
 DEF("boot", HAS_ARG, QEMU_OPTION_boot,
     "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
     "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
     "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
     QEMU_ARCH_ALL)
 STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
 @findex -boot
 Specify boot order @var{drives} as a string of drive letters. Valid
 drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,9 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
 format(true color). The resolution should be supported by the SVGA mode, so
 the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot.
+
 @example
 # try to boot from network first, then from hard disk
 qemu-system-i386 -boot order=nc
vl.c +2 -1
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                 {
                     static const char * const params[] = {
                         "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                     };
                     char buf[sizeof(boot_devices)];
                     char *standard_boot_devices;
Signature · 1 line
1.7.1

--
Gleb.

#5 lore raw
In reply to Amos Kong
Quoted 8 lines · Amos Kong

Hi all,

Seabios supports automatically reboot after X second delay on failed boot [1],
I want to add a parameter for qemu, it's used put a boot parameter into romfile
for seabios to set the delay time.

Quoted 4 lines
# qemu ... -boot order=n,menu=on,delay=5 ...

Comments & suggestions ? Thanks!

Why use a file and not just a key/value?

Regards,

Anthony Liguori

Quoted 18 lines

[1] commit b8fcf46826e77c835da0ad8127a17895bb2e2fca

Author: Kevin O'Connor <[email protected]>
Date:   Sat May 12 22:12:22 2012 -0400

Automatically reboot after 60 second delay on failed boot.

If no valid boot devices are found, display the error for 60 seconds (by default) and then reboot. This enables a periodic retry in case one of the boot devices is still coming online.

Signature · 1 line
			Amos.
#6 lore raw

I'm just guessing, but perhaps because a file can be changed without rebuilding SeaBIOS.

----- Original Message -----
From: "Anthony Liguori" <[email protected]>
To: "Amos Kong" <[email protected]>
Cc: [email protected], [email protected]
Sent: Thursday, September 6, 2012 7:36:24 AM
Subject: Re: [SeaBIOS] [Qemu-devel] RFC: Add a new boot parameter to set delay time before seabios retry to boot

Quoted 8 lines · Amos Kong

Hi all,

Seabios supports automatically reboot after X second delay on failed boot [1],
I want to add a parameter for qemu, it's used put a boot parameter into romfile
for seabios to set the delay time.

Quoted 4 lines
# qemu ... -boot order=n,menu=on,delay=5 ...

Comments & suggestions ? Thanks!

Why use a file and not just a key/value?

Regards,

Anthony Liguori

Quoted 6 lines

[1] commit b8fcf46826e77c835da0ad8127a17895bb2e2fca

Author: Kevin O'Connor <[email protected]>
Date:   Sat May 12 22:12:22 2012 -0400
Quoted 12 lines

Automatically reboot after 60 second delay on failed boot.

If no valid boot devices are found, display the error for 60 seconds (by default) and then reboot. This enables a periodic retry in case one of the boot devices is still coming online.

Signature · 1 line
			Amos.

_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

#7 lore raw
In reply to Anthony Liguori
Quoted 10 lines · Anthony Liguori
Quoted 8 lines · Amos Kong

Hi all,

Seabios supports automatically reboot after X second delay on failed boot [1],
I want to add a parameter for qemu, it's used put a boot parameter into romfile
for seabios to set the delay time.

Quoted 6 lines
Quoted 4 lines
# qemu ... -boot order=n,menu=on,delay=5 ...

Comments & suggestions ? Thanks!

Why use a file and not just a key/value?

SeaBIOS already accepts a number of run-time config settings (such as the reboot delay) via helper functions. For example:

    u32 retrytime = romfile_loadint("etc/boot-fail-wait", 60*1000);

On QEMU, the above will pull the value from the fwcfg "file" interface. The "file" interface is used because SeaBIOS needs a reliable way of obtaining a name, value size, and value. It in no way requires that there be a real file on the user's host machine.

-Kevin

author
#4 lore raw

Re: [Qemu-devel] [PATCH] add a boot parameter to set reboot timeout

In reply to Gleb Natapov
Quoted 11 lines · Gleb Natapov
Quoted 9 lines · Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. This feature need the new seabios's support.

IMO default should be no reboot just like before Seabios change.

Seabios reboots in 60s by default.

And I agree with you, will pass a '-1' to seabios by default, then the default behavior of qemu is no-reboot.

Thanks, Amos

Quoted 121 lines
Quoted 116 lines
---
  hw/fw_cfg.c     |   29 +++++++++++++++++++++++++++++
  qemu-config.c   |    3 +++
  qemu-options.hx |   10 +++++++---
  vl.c            |    3 ++-
  4 files changed, 41 insertions(+), 4 deletions(-)
hw/fw_cfg.c +29 -0
index 7b3b576..a017184 100644
@@ -183,6 +183,34 @@ static void fw_cfg_bootsplash(FWCfgState *s)
      }
  }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    if (reboot_timeout >= 0) {
+        /* validate the input */
+        if (reboot_timeout > 0xffff) {
+            error_report("reboot timeout is larger than 65535,"
+                         " force it to 65535.");
+            reboot_timeout = 0xffff;
+        }
+       fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4),
+                       4);
+    }
+}
+
  static void fw_cfg_write(FWCfgState *s, uint8_t value)
  {
      int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +525,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
      fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
      fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
      fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
      s->machine_ready.notify = fw_cfg_machine_ready;
      qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
          }, {
              .name = "splash-time",
              .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
          },
          { /*End of list */ }
      },
qemu-options.hx +7 -3
index 3c411c4..d50505b 100644
@@ -339,13 +339,14 @@ ETEXI
 
  DEF("boot", HAS_ARG, QEMU_OPTION_boot,
      "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
      "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
      "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
      QEMU_ARCH_ALL)
  STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
  @findex -boot
  Specify boot order @var{drives} as a string of drive letters. Valid
  drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,9 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
  format(true color). The resolution should be supported by the SVGA mode, so
  the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot.
+
  @example
  # try to boot from network first, then from hard disk
  qemu-system-i386 -boot order=nc
vl.c +2 -2
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                  {
                      static const char * const params[] = {
                          "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                      };
                      char buf[sizeof(boot_devices)];
                      char *standard_boot_devices;
--
Quoted 1 line

1.7.1

--
Gleb.

Signature · 1 line
			Amos.
author
#8 lore raw

PATCH v2 1/1 add a boot parameter to set reboot timeout

In reply to Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. If reboot-timeout is '-1', guest will not reboot, qemu passes '-1' to bios by default.

This feature need the new seabios's support.

Seabios pulls the value from the fwcfg "file" interface, this interface is used because SeaBIOS needs a reliable way of obtaining a name, value size, and value. It in no way requires that there be a real file on the user's host machine.

---
v2: qemu passes '-1' to bios, guest will not reboot

---
 hw/fw_cfg.c     |   25 +++++++++++++++++++++++++
 qemu-config.c   |    3 +++
 qemu-options.hx |   12 +++++++++---
 vl.c            |    3 ++-
 4 files changed, 39 insertions(+), 4 deletions(-)
hw/fw_cfg.c +25 -0
index 7b3b576..dcde1a9 100644
@@ -183,6 +183,30 @@ static void fw_cfg_bootsplash(FWCfgState *s)
     }
 }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    /* validate the input */
+    if (reboot_timeout > 0xffff) {
+        error_report("reboot timeout is larger than 65535, force it to 65535.");
+        reboot_timeout = 0xffff;
+    }
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4);
+}
+
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
 {
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +521,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
     fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
     s->machine_ready.notify = fw_cfg_machine_ready;
     qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
         }, {
             .name = "splash-time",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
         },
         { /*End of list */ }
     },
qemu-options.hx +9 -3
index 3c411c4..0249a60 100644
@@ -339,13 +339,14 @@ ETEXI
 
 DEF("boot", HAS_ARG, QEMU_OPTION_boot,
     "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
     "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
     "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
     QEMU_ARCH_ALL)
 STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
 @findex -boot
 Specify boot order @var{drives} as a string of drive letters. Valid
 drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,11 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
 format(true color). The resolution should be supported by the SVGA mode, so
 the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not
+reboot, qemu passes '-1' to bios by default. Currently Seabios for X86
+system support it.
+
 @example
 # try to boot from network first, then from hard disk
 qemu-system-i386 -boot order=nc
vl.c +2 -1
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                 {
                     static const char * const params[] = {
                         "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                     };
                     char buf[sizeof(boot_devices)];
                     char *standard_boot_devices;
Signature · 1 line
1.7.1
author
#9 lore raw

Re: [Qemu-devel] [PATCH v2] add a boot parameter to set reboot timeout

Quoted 11 lines · Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. If reboot-timeout is '-1', guest will not reboot, qemu passes '-1' to bios by default.

This feature need the new seabios's support.

Quoted 8 lines

Seabios pulls the value from the fwcfg "file" interface, this interface is used because SeaBIOS needs a reliable way of obtaining a name, value size, and value. It in no way requires that there be a real file on the user's host machine.

---
v2: qemu passes '-1' to bios, guest will not reboot

Gleb, Anthony, any comments?

Quoted 113 lines
---
  hw/fw_cfg.c     |   25 +++++++++++++++++++++++++
  qemu-config.c   |    3 +++
  qemu-options.hx |   12 +++++++++---
  vl.c            |    3 ++-
  4 files changed, 39 insertions(+), 4 deletions(-)
hw/fw_cfg.c +25 -0
index 7b3b576..dcde1a9 100644
@@ -183,6 +183,30 @@ static void fw_cfg_bootsplash(FWCfgState *s)
      }
  }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    /* validate the input */
+    if (reboot_timeout > 0xffff) {
+        error_report("reboot timeout is larger than 65535, force it to 65535.");
+        reboot_timeout = 0xffff;
+    }
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4);
+}
+
  static void fw_cfg_write(FWCfgState *s, uint8_t value)
  {
      int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +521,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
      fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
      fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
      fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
      s->machine_ready.notify = fw_cfg_machine_ready;
      qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
          }, {
              .name = "splash-time",
              .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
          },
          { /*End of list */ }
      },
qemu-options.hx +9 -3
index 3c411c4..0249a60 100644
@@ -339,13 +339,14 @@ ETEXI
 
  DEF("boot", HAS_ARG, QEMU_OPTION_boot,
      "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
      "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
      "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
      QEMU_ARCH_ALL)
  STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
  @findex -boot
  Specify boot order @var{drives} as a string of drive letters. Valid
  drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,11 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
  format(true color). The resolution should be supported by the SVGA mode, so
  the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not
+reboot, qemu passes '-1' to bios by default. Currently Seabios for X86
+system support it.
+
  @example
  # try to boot from network first, then from hard disk
  qemu-system-i386 -boot order=nc
vl.c +2 -1
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                  {
                      static const char * const params[] = {
                          "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                      };
                      char buf[sizeof(boot_devices)];
                      char *standard_boot_devices;
Signature · 1 line
			Amos.
#10 lore raw

Re: [Qemu-devel] [PATCH v2] add a boot parameter to set reboot timeout

Quoted 17 lines · Amos Kong
Quoted 16 lines · Amos Kong

Added an option to let qemu transfer a configuration file to bios, "etc/boot-fail-wait", which could be specified by command
-boot reboot-timeout=T
T have a max value of 0xffff, unit is ms.

With this option, guest will wait for a given time if not find bootabled device, then reboot. If reboot-timeout is '-1', guest will not reboot, qemu passes '-1' to bios by default.

This feature need the new seabios's support.

Seabios pulls the value from the fwcfg "file" interface, this interface is used because SeaBIOS needs a reliable way of obtaining a name, value size, and value. It in no way requires that there be a real file on the user's host machine.

Quoted 7 lines
Quoted 3 lines

---
v2: qemu passes '-1' to bios, guest will not reboot

Gleb, Anthony, any comments?

Not from me. Looks good.

Quoted 105 lines
Quoted 105 lines
---
 hw/fw_cfg.c     |   25 +++++++++++++++++++++++++
 qemu-config.c   |    3 +++
 qemu-options.hx |   12 +++++++++---
 vl.c            |    3 ++-
 4 files changed, 39 insertions(+), 4 deletions(-)
hw/fw_cfg.c +25 -0
index 7b3b576..dcde1a9 100644
@@ -183,6 +183,30 @@ static void fw_cfg_bootsplash(FWCfgState *s)
     }
 }
 
+static void fw_cfg_reboot(FWCfgState *s)
+{
+    int reboot_timeout = -1;
+    char *p;
+    const char *temp;
+
+    /* get user configuration */
+    QemuOptsList *plist = qemu_find_opts("boot-opts");
+    QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+    if (opts != NULL) {
+        temp = qemu_opt_get(opts, "reboot-timeout");
+        if (temp != NULL) {
+            p = (char *)temp;
+            reboot_timeout = strtol(p, (char **)&p, 10);
+        }
+    }
+    /* validate the input */
+    if (reboot_timeout > 0xffff) {
+        error_report("reboot timeout is larger than 65535, force it to 65535.");
+        reboot_timeout = 0xffff;
+    }
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4);
+}
+
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
 {
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
@@ -497,6 +521,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
     fw_cfg_bootsplash(s);
+    fw_cfg_reboot(s);
 
     s->machine_ready.notify = fw_cfg_machine_ready;
     qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu-config.c +3 -0
index c05ffbc..b9f9e0f 100644
@@ -638,6 +638,9 @@ QemuOptsList qemu_boot_opts = {
         }, {
             .name = "splash-time",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "reboot-timeout",
+            .type = QEMU_OPT_STRING,
         },
         { /*End of list */ }
     },
qemu-options.hx +9 -3
index 3c411c4..0249a60 100644
@@ -339,13 +339,14 @@ ETEXI
 
 DEF("boot", HAS_ARG, QEMU_OPTION_boot,
     "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time]\n"
+    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n"
     "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
     "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n",
+    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
+    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
     QEMU_ARCH_ALL)
 STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}]
+@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}]
 @findex -boot
 Specify boot order @var{drives} as a string of drive letters. Valid
 drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -364,6 +365,11 @@ limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
 format(true color). The resolution should be supported by the SVGA mode, so
 the recommended is 320x240, 640x480, 800x640.
 
+A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not
+reboot, qemu passes '-1' to bios by default. Currently Seabios for X86
+system support it.
+
 @example
 # try to boot from network first, then from hard disk
 qemu-system-i386 -boot order=nc
vl.c +0 -0
index 7c577fa..1bd9931 100644
@@ -2622,7 +2622,8 @@ int main(int argc, char **argv, char **envp)
                 {
                     static const char * const params[] = {
Quoted 11 lines
Quoted 8 lines
vl.c +2 -1
                         "order", "once", "menu",
-                        "splash", "splash-time", NULL
+                        "splash", "splash-time",
+                        "reboot-timeout", NULL
                     };
                     char buf[sizeof(boot_devices)];
                     char *standard_boot_devices;
Signature · 1 line
			Amos.

--
Gleb.