qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: jan.kiszka@siemens.com, alex.williamson@redhat.com,
	afaerber@suse.de, aviksil@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v3 01/16] vl: Clean up parsing of -boot option argument
Date: Fri, 14 Jun 2013 08:36:19 -0500	[thread overview]
Message-ID: <871u84hl0s.fsf@codemonkey.ws> (raw)
In-Reply-To: <1371208516-7857-2-git-send-email-armbru@redhat.com>

Markus Armbruster <armbru@redhat.com> writes:

> Commit 3d3b8303 threw in some QemuOpts parsing without replacing the
> existing ad hoc parser, resulting in a confusing mess.  Clean it up.
>
> Two user-visible changes:
>
> 1. Invalid options are reported more nicely.  Before:
>
>         qemu: unknown boot parameter 'x' in 'x=y'
>
>    After:
>
>         qemu-system-x86_64: -boot x=y: Invalid parameter 'x'
>
> 2. If -boot is given multiple times, options accumulate, just like for
>    -machine.  Before, only options order, once and menu accumulated.
>    For the other ones, all but the first -boot in non-legacy syntax
>    got simply ignored.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>  vl.c | 84 ++++++++++++++++++--------------------------------------------------
>  1 file changed, 22 insertions(+), 62 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 180fdde..a0ac6e9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -436,9 +436,10 @@ static QemuOptsList qemu_machine_opts = {
>  
>  static QemuOptsList qemu_boot_opts = {
>      .name = "boot-opts",
> +    .implied_opt_name = "order",
> +    .merge_lists = true,
>      .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
>      .desc = {
> -        /* the three names below are not used now */
>          {
>              .name = "order",
>              .type = QEMU_OPT_STRING,
> @@ -447,8 +448,7 @@ static QemuOptsList qemu_boot_opts = {
>              .type = QEMU_OPT_STRING,
>          }, {
>              .name = "menu",
> -            .type = QEMU_OPT_STRING,
> -        /* following are really used */
> +            .type = QEMU_OPT_BOOL,
>          }, {
>              .name = "splash",
>              .type = QEMU_OPT_STRING,
> @@ -1159,7 +1159,7 @@ int qemu_boot_set(const char *boot_devices)
>      return boot_set_handler(boot_set_opaque, boot_devices);
>  }
>  
> -static void validate_bootdevices(char *devices)
> +static void validate_bootdevices(const char *devices)
>  {
>      /* We just do some generic consistency checks */
>      const char *p;
> @@ -3134,70 +3134,30 @@ int main(int argc, char **argv, char **envp)
>                  break;
>              case QEMU_OPTION_boot:
>                  {
> -                    static const char * const params[] = {
> -                        "order", "once", "menu",
> -                        "splash", "splash-time",
> -                        "reboot-timeout", "strict", NULL
> -                    };
> -                    char buf[sizeof(boot_devices)];
>                      char *standard_boot_devices;
> -                    int legacy = 0;
> -
> -                    if (!strchr(optarg, '=')) {
> -                        legacy = 1;
> -                        pstrcpy(buf, sizeof(buf), optarg);
> -                    } else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
> -                        fprintf(stderr,
> -                                "qemu: unknown boot parameter '%s' in '%s'\n",
> -                                buf, optarg);
> +                    const char *order, *once;
> +
> +                    opts = qemu_opts_parse(qemu_find_opts("boot-opts"),
> +                                           optarg, 1);
> +                    if (!opts) {
>                          exit(1);
>                      }
>  
> -                    if (legacy ||
> -                        get_param_value(buf, sizeof(buf), "order", optarg)) {
> -                        validate_bootdevices(buf);
> -                        pstrcpy(boot_devices, sizeof(boot_devices), buf);
> +                    order = qemu_opt_get(opts, "order");
> +                    if (order) {
> +                        validate_bootdevices(order);
> +                        pstrcpy(boot_devices, sizeof(boot_devices), order);
>                      }
> -                    if (!legacy) {
> -                        if (get_param_value(buf, sizeof(buf),
> -                                            "once", optarg)) {
> -                            validate_bootdevices(buf);
> -                            standard_boot_devices = g_strdup(boot_devices);
> -                            pstrcpy(boot_devices, sizeof(boot_devices), buf);
> -                            qemu_register_reset(restore_boot_devices,
> -                                                standard_boot_devices);
> -                        }
> -                        if (get_param_value(buf, sizeof(buf),
> -                                            "menu", optarg)) {
> -                            if (!strcmp(buf, "on")) {
> -                                boot_menu = 1;
> -                            } else if (!strcmp(buf, "off")) {
> -                                boot_menu = 0;
> -                            } else {
> -                                fprintf(stderr,
> -                                        "qemu: invalid option value '%s'\n",
> -                                        buf);
> -                                exit(1);
> -                            }
> -                        }
> -                        if (get_param_value(buf, sizeof(buf),
> -                                            "strict", optarg)) {
> -                            if (!strcmp(buf, "on")) {
> -                                boot_strict = true;
> -                            } else if (!strcmp(buf, "off")) {
> -                                boot_strict = false;
> -                            } else {
> -                                fprintf(stderr,
> -                                        "qemu: invalid option value '%s'\n",
> -                                        buf);
> -                                exit(1);
> -                            }
> -                        }
> -                        if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
> -                                             optarg, 0)) {
> -                            exit(1);
> -                        }
> +
> +                    once = qemu_opt_get(opts, "once");
> +                    if (once) {
> +                        validate_bootdevices(once);
> +                        standard_boot_devices = g_strdup(boot_devices);
> +                        pstrcpy(boot_devices, sizeof(boot_devices), once);
> +                        qemu_register_reset(restore_boot_devices,
> +                                            standard_boot_devices);
>                      }
> +                    boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
>                  }
>                  break;
>              case QEMU_OPTION_fda:
> -- 
> 1.7.11.7

  reply	other threads:[~2013-06-14 13:39 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14 11:15 [Qemu-devel] [PATCH v3 00/16] -boot and -no-fd-bootchk fixes Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 01/16] vl: Clean up parsing of -boot option argument Markus Armbruster
2013-06-14 13:36   ` Anthony Liguori [this message]
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 02/16] qemu-option: check_params() is now unused, drop it Markus Armbruster
2013-06-14 13:36   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 03/16] vl: Fix -boot order and once regressions, and related bugs Markus Armbruster
2013-06-14 13:38   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 04/16] vl: Rename *boot_devices to *boot_order, for consistency Markus Armbruster
2013-06-14 13:38   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 05/16] pc: Make -no-fd-bootchk stick across boot order changes Markus Armbruster
2013-06-14 13:40   ` Anthony Liguori
2013-06-18 11:39     ` Markus Armbruster
2013-07-08  1:24       ` Kevin O'Connor
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 06/16] doc: Drop ref to Bochs from -no-fd-bootchk documentation Markus Armbruster
2013-06-14 13:41   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 07/16] qtest: Don't reset on qtest chardev connect Markus Armbruster
2013-06-14 13:44   ` Anthony Liguori
2013-06-18 11:41     ` Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 08/16] boot-order-test: New; covering just PC for now Markus Armbruster
2013-06-14 13:48   ` Anthony Liguori
2013-06-18 13:33     ` Markus Armbruster
2013-06-18 14:13       ` Andreas Färber
2013-06-18 15:02       ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 09/16] boot-order-test: Add tests for PowerMacs Markus Armbruster
2013-06-14 13:49   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 10/16] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
2013-06-14 13:50   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 11/16] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
2013-06-14 13:52   ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 12/16] boot-order-test: Code motion for better readability Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 13/16] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 14/16] boot-order-test: Add tests for Sun4m Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 15/16] boot-order-test: Support fw_cfg in I/O space Markus Armbruster
2013-06-14 13:53   ` Anthony Liguori
2013-06-14 14:04     ` Andreas Färber
2013-06-19  6:49     ` Markus Armbruster
2013-06-19 18:47       ` Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 16/16] boot-order-test: Add tests for Sun4u Markus Armbruster
2013-06-21 15:34 ` [Qemu-devel] [PATCH v3 00/16] -boot and -no-fd-bootchk fixes 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=871u84hl0s.fsf@codemonkey.ws \
    --to=aliguori@us.ibm.com \
    --cc=afaerber@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=aviksil@linux.vnet.ibm.com \
    --cc=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 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).