thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
218e99
From 5575e0aec51f40ebec46e98ec085cda053283aba Mon Sep 17 00:00:00 2001
218e99
Message-Id: <5575e0aec51f40ebec46e98ec085cda053283aba.1383564115.git.minovotn@redhat.com>
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
Date: Fri, 27 Sep 2013 13:31:11 +0200
218e99
Subject: [PATCH 01/14] vl: Clean up parsing of -boot option argument
218e99
218e99
RH-Author: Markus Armbruster <armbru@redhat.com>
218e99
Message-id: <1380288680-26645-2-git-send-email-armbru@redhat.com>
218e99
Patchwork-id: 54560
218e99
O-Subject: [PATCH 7.0 qemu-kvm 01/10] vl: Clean up parsing of -boot option argument
218e99
Bugzilla: 997817
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
218e99
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
218e99
Commit 3d3b8303 threw in some QemuOpts parsing without replacing the
218e99
existing ad hoc parser, resulting in a confusing mess.  Clean it up.
218e99
218e99
Two user-visible changes:
218e99
218e99
1. Invalid options are reported more nicely.  Before:
218e99
218e99
        qemu: unknown boot parameter 'x' in 'x=y'
218e99
218e99
   After:
218e99
218e99
        qemu-system-x86_64: -boot x=y: Invalid parameter 'x'
218e99
218e99
2. If -boot is given multiple times, options accumulate, just like for
218e99
   -machine.  Before, only options order, once and menu accumulated.
218e99
   For the other ones, all but the first -boot in non-legacy syntax
218e99
   got simply ignored.
218e99
218e99
Signed-off-by: Markus Armbruster <armbru@redhat.com>
218e99
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
218e99
Message-id: 1371208516-7857-2-git-send-email-armbru@redhat.com
218e99
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
218e99
(cherry picked from commit 6ef4716cecdfa1b3794c1a33edba9840e1aa6b5f)
218e99
---
218e99
 vl.c | 84 ++++++++++++++++++--------------------------------------------------
218e99
 1 file changed, 22 insertions(+), 62 deletions(-)
218e99
218e99
Signed-off-by: Michal Novotny <minovotn@redhat.com>
218e99
---
218e99
 vl.c | 84 ++++++++++++++++++--------------------------------------------------
218e99
 1 file changed, 22 insertions(+), 62 deletions(-)
218e99
218e99
diff --git a/vl.c b/vl.c
218e99
index a40ab13..a5663ad 100644
218e99
--- a/vl.c
218e99
+++ b/vl.c
218e99
@@ -436,9 +436,10 @@ static QemuOptsList qemu_machine_opts = {
218e99
 
218e99
 static QemuOptsList qemu_boot_opts = {
218e99
     .name = "boot-opts",
218e99
+    .implied_opt_name = "order",
218e99
+    .merge_lists = true,
218e99
     .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
218e99
     .desc = {
218e99
-        /* the three names below are not used now */
218e99
         {
218e99
             .name = "order",
218e99
             .type = QEMU_OPT_STRING,
218e99
@@ -447,8 +448,7 @@ static QemuOptsList qemu_boot_opts = {
218e99
             .type = QEMU_OPT_STRING,
218e99
         }, {
218e99
             .name = "menu",
218e99
-            .type = QEMU_OPT_STRING,
218e99
-        /* following are really used */
218e99
+            .type = QEMU_OPT_BOOL,
218e99
         }, {
218e99
             .name = "splash",
218e99
             .type = QEMU_OPT_STRING,
218e99
@@ -1114,7 +1114,7 @@ int qemu_boot_set(const char *boot_devices)
218e99
     return boot_set_handler(boot_set_opaque, boot_devices);
218e99
 }
218e99
 
218e99
-static void validate_bootdevices(char *devices)
218e99
+static void validate_bootdevices(const char *devices)
218e99
 {
218e99
     /* We just do some generic consistency checks */
218e99
     const char *p;
218e99
@@ -3087,70 +3087,30 @@ int main(int argc, char **argv, char **envp)
218e99
                 break;
218e99
             case QEMU_OPTION_boot:
218e99
                 {
218e99
-                    static const char * const params[] = {
218e99
-                        "order", "once", "menu",
218e99
-                        "splash", "splash-time",
218e99
-                        "reboot-timeout", "strict", NULL
218e99
-                    };
218e99
-                    char buf[sizeof(boot_devices)];
218e99
                     char *standard_boot_devices;
218e99
-                    int legacy = 0;
218e99
-
218e99
-                    if (!strchr(optarg, '=')) {
218e99
-                        legacy = 1;
218e99
-                        pstrcpy(buf, sizeof(buf), optarg);
218e99
-                    } else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
218e99
-                        fprintf(stderr,
218e99
-                                "qemu: unknown boot parameter '%s' in '%s'\n",
218e99
-                                buf, optarg);
218e99
+                    const char *order, *once;
218e99
+
218e99
+                    opts = qemu_opts_parse(qemu_find_opts("boot-opts"),
218e99
+                                           optarg, 1);
218e99
+                    if (!opts) {
218e99
                         exit(1);
218e99
                     }
218e99
 
218e99
-                    if (legacy ||
218e99
-                        get_param_value(buf, sizeof(buf), "order", optarg)) {
218e99
-                        validate_bootdevices(buf);
218e99
-                        pstrcpy(boot_devices, sizeof(boot_devices), buf);
218e99
+                    order = qemu_opt_get(opts, "order");
218e99
+                    if (order) {
218e99
+                        validate_bootdevices(order);
218e99
+                        pstrcpy(boot_devices, sizeof(boot_devices), order);
218e99
                     }
218e99
-                    if (!legacy) {
218e99
-                        if (get_param_value(buf, sizeof(buf),
218e99
-                                            "once", optarg)) {
218e99
-                            validate_bootdevices(buf);
218e99
-                            standard_boot_devices = g_strdup(boot_devices);
218e99
-                            pstrcpy(boot_devices, sizeof(boot_devices), buf);
218e99
-                            qemu_register_reset(restore_boot_devices,
218e99
-                                                standard_boot_devices);
218e99
-                        }
218e99
-                        if (get_param_value(buf, sizeof(buf),
218e99
-                                            "menu", optarg)) {
218e99
-                            if (!strcmp(buf, "on")) {
218e99
-                                boot_menu = 1;
218e99
-                            } else if (!strcmp(buf, "off")) {
218e99
-                                boot_menu = 0;
218e99
-                            } else {
218e99
-                                fprintf(stderr,
218e99
-                                        "qemu: invalid option value '%s'\n",
218e99
-                                        buf);
218e99
-                                exit(1);
218e99
-                            }
218e99
-                        }
218e99
-                        if (get_param_value(buf, sizeof(buf),
218e99
-                                            "strict", optarg)) {
218e99
-                            if (!strcmp(buf, "on")) {
218e99
-                                boot_strict = true;
218e99
-                            } else if (!strcmp(buf, "off")) {
218e99
-                                boot_strict = false;
218e99
-                            } else {
218e99
-                                fprintf(stderr,
218e99
-                                        "qemu: invalid option value '%s'\n",
218e99
-                                        buf);
218e99
-                                exit(1);
218e99
-                            }
218e99
-                        }
218e99
-                        if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
218e99
-                                             optarg, 0)) {
218e99
-                            exit(1);
218e99
-                        }
218e99
+
218e99
+                    once = qemu_opt_get(opts, "once");
218e99
+                    if (once) {
218e99
+                        validate_bootdevices(once);
218e99
+                        standard_boot_devices = g_strdup(boot_devices);
218e99
+                        pstrcpy(boot_devices, sizeof(boot_devices), once);
218e99
+                        qemu_register_reset(restore_boot_devices,
218e99
+                                            standard_boot_devices);
218e99
                     }
218e99
+                    boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
218e99
                 }
218e99
                 break;
218e99
             case QEMU_OPTION_fda:
218e99
-- 
218e99
1.7.11.7
218e99