qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Add args for quiet and prompt
Date: Sat, 14 Feb 2009 16:27:49 -0600	[thread overview]
Message-ID: <49974565.6010706@codemonkey.ws> (raw)
In-Reply-To: <1234421329-8119-3-git-send-email-FOSS@AtlasTechnologiesInc.com>

Cory Fields wrote:
> Syntax is -boot [cad],prompt=x,quiet=x where x is [0,1,true,false]
> Boot drive is mandatory
> If prompt is set user will see "Press f12 for boot menu"
> This behavior has changed, it is now off by default
>
> If quiet is set user will see no normal text output from bios.
> Errors will stil be displayed.
>
> Signed-off-by: Cory Fields <FOSS@AtlasTechnologiesInc.com>
> ---
>  vl.c |   48 ++++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 3676537..b2da109 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -230,6 +230,9 @@ int no_shutdown = 0;
>  int cursor_hide = 1;
>  int graphic_rotate = 0;
>  int daemonize = 0;
> +int biosprompt = 0;
> +int quietbios = 0;
> +
>  const char *option_rom[MAX_OPTION_ROMS];
>  int nb_option_roms;
>  int semihosting_enabled = 0;
> @@ -3875,6 +3878,10 @@ 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"
> +           "      [,quiet=true|false]\n"
> +           "                hide bios text [default=false]\n"
> +           "      [,prompt=true|false]\n"
> +           "                hide boot menu prompt [default=true]\n"
>             "-snapshot       write to temporary files instead of disk image files\n"
>             "-m megs         set virtual RAM size to megs MB [default=%d]\n"
>  #ifndef _WIN32
> @@ -4556,7 +4563,7 @@ int main(int argc, char **argv, char **envp)
>      int snapshot, linux_boot, net_boot;
>      const char *initrd_filename;
>      const char *kernel_filename, *kernel_cmdline;
> -    const char *boot_devices = "";
> +    char boot_devices[32] = "";
>      DisplayState *ds;
>      DisplayChangeListener *dcl;
>      int cyls, heads, secs, translation;
> @@ -4829,14 +4836,15 @@ int main(int argc, char **argv, char **envp)
>                  drive_add(optarg, CDROM_ALIAS);
>                  break;
>              case QEMU_OPTION_boot:
> -                boot_devices = optarg;
>                  /* We just do some generic consistency checks */
>                  {
>                      /* Could easily be extended to 64 devices if needed */
>                      const char *p;
> +                    int num_drive_letters = 0;  
> +                    char boot_opts[128];
>                      
>                      boot_devices_bitmap = 0;
> -                    for (p = boot_devices; *p != '\0'; p++) {
> +                    for (p = optarg; *p != '\0' && *p != ','; p++) {
>                          /* Allowed boot devices are:
>                           * a b     : floppy disk drives
>                           * c ... f : IDE disk drives
> @@ -4856,6 +4864,38 @@ int main(int argc, char **argv, char **envp)
>                              exit(1);
>                          }
>                          boot_devices_bitmap |= 1 << (*p - 'a');
> +                        boot_devices[num_drive_letters]=*p;
> +                        num_drive_letters++;
> +
> +                    }
> +                    
> +                    strcpy(boot_opts,optarg);
>   

snprintf(), optarg has no bounds and boot_opts does.

> +                    if (*p == ',') p++;
> +                    if (get_param_value(boot_opts, sizeof(boot_opts), "quiet", p)) {
> +                      if (!strcmp(boot_opts, "true") || !strcmp(boot_opts, "1")) {
> +                        quietbios=1;
> +                        biosprompt=0;
> +                         }
>   

The whitespace looks a little weird to me.

> +                      else if (!strcmp(boot_opts, "false") || !strcmp(boot_opts, "0")) {
> +                        quietbios=0;
> +                      }
> +                      else {
> +                        printf("Boot option not recognized\n");
> +                        exit(1);
> +                      }
> +                    }
> +
> +                    if (get_param_value(boot_opts, sizeof(boot_opts), "prompt", p)){
> +                      if (!strcmp(boot_opts, "true") || !strcmp(boot_opts, "1")) {
> +                        biosprompt=1;
> +                      }
> +                      else if (!strcmp(boot_opts, "false") || !strcmp(boot_opts, "0"))  {
> +                        biosprompt=0;
> +                      }
> +                      else {
> +                        printf("Boot option not recognized\n");
> +                        exit(1);
> +                      }
>                      }
>   

This all looks like 2-space tabs, QEMU uses 4-space tabs.  I'd suggest 
factoring this out into a separate function too.

Regards,

Anthony Liguori

>                  }
>                  break;
> @@ -5343,7 +5383,7 @@ int main(int argc, char **argv, char **envp)
>  
>      /* boot to floppy or the default cd if no hard disk defined yet */
>      if (!boot_devices[0]) {
> -        boot_devices = "cad";
> +        strcpy(boot_devices,"cad");
>      }
>      setvbuf(stdout, NULL, _IOLBF, 0);
>  
>   

  parent reply	other threads:[~2009-02-14 22:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12  6:48 [Qemu-devel] [PATCH 0/4] Cory Fields
2009-02-12  6:48 ` [Qemu-devel] [PATCH] Define a new route for sending data to bios Cory Fields
2009-02-12  6:41   ` Gleb Natapov
2009-02-12 15:50     ` Blue Swirl
2009-02-12  6:48 ` [Qemu-devel] [PATCH] Add args for quiet and prompt Cory Fields
2009-02-12 10:42   ` Kevin Wolf
2009-02-14 22:27   ` Anthony Liguori [this message]
2009-02-15  0:07     ` Cory Fields
2009-02-12  6:48 ` [Qemu-devel] [PATCH] enable quietbios and biosprompt checks Cory Fields
2009-02-14 22:28   ` Anthony Liguori
2009-02-15  0:09     ` Cory Fields
2009-02-12  6:48 ` [Qemu-devel] [PATCH] enable quietbios check Cory Fields
  -- strict thread matches above, loose matches on Subject: below --
2009-02-14 23:57 [Qemu-devel] [PATCH 0/4] Option to suppress bios output and prompt (v2) Cory Fields
2009-02-14 23:57 ` [Qemu-devel] [PATCH] Add args for quiet and prompt Cory Fields

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=49974565.6010706@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --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 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).