qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: aliguori@us.ibm.com, seabios@seabios.org, dallan@redhat.com,
	qemu-devel@nongnu.org, kevin@koconnor.net
Subject: Re: [Qemu-devel] [Qemu PATCH] add a boot option to do strict boot
Date: Wed, 9 Jan 2013 09:54:03 +0200	[thread overview]
Message-ID: <20130109075403.GA16739@redhat.com> (raw)
In-Reply-To: <1357716867-1190-1-git-send-email-akong@redhat.com>

On Wed, Jan 09, 2013 at 03:34:27PM +0800, Amos Kong wrote:
> Current seabios will try to boot from selected devices first,
> if they are all failed, seabios will also try to boot from
> un-selected devices.
> 
> We need to make it configurable. I already posted a seabios
> patch to add a new device type to halt booting. Qemu can add
> "HALT" at the end of bootindex string, then seabios will halt
> booting after trying to boot from selected devices.
> 
> This option only effects when boot priority is changed by
> bootindex options, the old style(-boot order=..) will still
> try to boot from un-selected devices.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> [SeaBIOS PATCH v3] boot: add a new type to halt booting
> https://github.com/kongove/seabios/commit/39aeded2da6254eab2c34de92371ce1cad5c793e
> bios.bin: http://kongove.fedorapeople.org/pub/added-halt-type-bios.bin
> ---
>  qemu-config.c   |    3 +++
>  qemu-options.hx |    8 ++++++--
>  vl.c            |   28 +++++++++++++++++++++++++++-
>  3 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/qemu-config.c b/qemu-config.c
> index 2188c3e..dd6d249 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -612,6 +612,9 @@ QemuOptsList qemu_boot_opts = {
>          }, {
>              .name = "reboot-timeout",
>              .type = QEMU_OPT_STRING,
> +        }, {
> +            .name = "strict",
> +            .type = QEMU_OPT_STRING,
>          },
>          { /*End of list */ }
>      },
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 9df0cde..5408837 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -376,14 +376,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][,reboot-timeout=rb_time]\n"
> +    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\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"
>      "                '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}][,reboot-timeout=@var{rb_timeout}]
> +@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}][,strict=on|off]
>  @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
> @@ -407,6 +407,10 @@ 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.
>  
> +Do strict boot via @option{strict=on} as far as firmware/BIOS
> +supports it. This only effects when boot priority is changed by
> +bootindex options. The default is non-strict boot.
> +
>  @example
>  # try to boot from network first, then from hard disk
>  qemu-system-i386 -boot order=nc
> diff --git a/vl.c b/vl.c
> index 79e5122..de79f6c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -230,6 +230,7 @@ int ctrl_grab = 0;
>  unsigned int nb_prom_envs = 0;
>  const char *prom_envs[MAX_PROM_ENVS];
>  int boot_menu;
> +int boot_strict;
bool?

>  uint8_t *boot_splash_filedata;
>  int boot_splash_filedata_size;
>  uint8_t qemu_extra_params_fw[2];
> @@ -2804,7 +2805,7 @@ int main(int argc, char **argv, char **envp)
>                      static const char * const params[] = {
>                          "order", "once", "menu",
>                          "splash", "splash-time",
> -                        "reboot-timeout", NULL
> +                        "reboot-timeout", "strict", NULL
>                      };
>                      char buf[sizeof(boot_devices)];
>                      char *standard_boot_devices;
> @@ -2847,6 +2848,19 @@ int main(int argc, char **argv, char **envp)
>                                  exit(1);
>                              }
>                          }
> +                        if (get_param_value(buf, sizeof(buf),
> +                                            "strict", optarg)) {
> +                            if (!strcmp(buf, "on")) {
> +                                boot_strict = 1;
> +                            } else if (!strcmp(buf, "off")) {
> +                                boot_strict = 0;
> +                            } else {
> +                                fprintf(stderr,
> +                                        "qemu: invalid option value '%s'\n",
> +                                        buf);
> +                                exit(1);
> +                            }
> +                        }
>                          qemu_opts_parse(qemu_find_opts("boot-opts"),
>                                          optarg, 0);
>                      }
> @@ -3907,6 +3921,18 @@ int main(int argc, char **argv, char **envp)
>  
>      net_check_clients();
>  
> +    if (boot_strict) {
> +        /* do strict boot, only boot from selected devices */
> +        FWBootEntry *node;
> +
> +        QTAILQ_FOREACH(node, &fw_boot_order, link) {
> +            if (!node->link.tqe_next) {
> +                add_boot_device_path(node->bootindex + 1, NULL, "HALT");
> +                break;
> +            }
> +        }
> +    }
> +
Just add HALT entry in get_boot_devices_list() if boot_strict==true.

>      /* just use the first displaystate for the moment */
>      ds = get_displaystate();
>  
> -- 
> 1.7.1

--
			Gleb.

  reply	other threads:[~2013-01-09  7:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09  7:34 [Qemu-devel] [Qemu PATCH] add a boot option to do strict boot Amos Kong
2013-01-09  7:54 ` Gleb Natapov [this message]
2013-01-09  8:39 ` [Qemu-devel] [Qemu PATCH v2] " Amos Kong
2013-01-09  9:56   ` Gleb Natapov
2013-01-09 15:14   ` Eric Blake
2013-01-09 15:22     ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2013-01-09 17:28       ` Laine Stump
2013-01-09 17:46         ` Gleb Natapov
2013-01-09 15:52     ` [Qemu-devel] " Amos Kong
     [not found]     ` <1974277572.9315720.1358868212597.JavaMail.root@redhat.com>
     [not found]       ` <20130122155229.GA9465@t430s.nay.redhat.com>
     [not found]         ` <50FEB79E.1040206@redhat.com>
     [not found]           ` <878v7ldqh0.fsf@codemonkey.ws>
     [not found]             ` <20130123104144.GA2419@t430s.nay.redhat.com>
     [not found]               ` <20130128031934.GA3986@t430s.nay.redhat.com>
2013-03-04 10:20                 ` [Qemu-devel] [RFC] introduce a general query-config cmd Amos Kong

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=20130109075403.GA16739@redhat.com \
    --to=gleb@redhat.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=dallan@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.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 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).