From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnUDz-0000G5-Ad for qemu-devel@nongnu.org; Fri, 14 Jun 2013 09:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnUDx-0005WY-M0 for qemu-devel@nongnu.org; Fri, 14 Jun 2013 09:39:31 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:39125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnUDx-0005WS-EX for qemu-devel@nongnu.org; Fri, 14 Jun 2013 09:39:29 -0400 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Jun 2013 07:39:27 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 555233E4007A for ; Fri, 14 Jun 2013 07:36:18 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5EDaQT8064410 for ; Fri, 14 Jun 2013 07:36:29 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5EDaQUA007138 for ; Fri, 14 Jun 2013 07:36:26 -0600 From: Anthony Liguori In-Reply-To: <1371208516-7857-2-git-send-email-armbru@redhat.com> References: <1371208516-7857-1-git-send-email-armbru@redhat.com> <1371208516-7857-2-git-send-email-armbru@redhat.com> Date: Fri, 14 Jun 2013 08:36:19 -0500 Message-ID: <871u84hl0s.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v3 01/16] vl: Clean up parsing of -boot option argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: jan.kiszka@siemens.com, alex.williamson@redhat.com, afaerber@suse.de, aviksil@linux.vnet.ibm.com Markus Armbruster 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 Reviewed-by: Anthony Liguori 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