[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/9] vl: enable system configuration to be used
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 5/9] vl: enable system configuration to be used |
Date: |
Mon, 19 Mar 2012 10:09:19 -0500 |
Now that we have options grouped, allow the [system] section to be used to set
these options.
Signed-off-by: Anthony Liguori <address@hidden>
---
vl.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/vl.c b/vl.c
index 9a7ad40..5e86311 100644
--- a/vl.c
+++ b/vl.c
@@ -2187,6 +2187,24 @@ static void qemu_run_machine_init_done_notifiers(void)
notifier_list_notify(&machine_init_done_notifiers, NULL);
}
+static const QEMUOption *find_opt_by_name(const char *name)
+{
+ const QEMUOption *popt;
+
+ popt = qemu_options;
+ for(;;) {
+ if (!popt->name) {
+ break;
+ }
+ if (!strcmp(popt->name, name)) {
+ return popt;
+ }
+ popt++;
+ }
+
+ return NULL;
+}
+
static const QEMUOption *lookup_opt(int argc, char **argv,
const char **poptarg, int *poptind)
{
@@ -2200,15 +2218,10 @@ static const QEMUOption *lookup_opt(int argc, char
**argv,
/* Treat --foo the same as -foo. */
if (r[1] == '-')
r++;
- popt = qemu_options;
- for(;;) {
- if (!popt->name) {
- error_report("invalid option");
- exit(1);
- }
- if (!strcmp(popt->name, r + 1))
- break;
- popt++;
+ popt = find_opt_by_name(r + 1);
+ if (popt == NULL) {
+ error_report("invalid option");
+ exit(1);
}
if (popt->flags & HAS_ARG) {
if (optind >= argc) {
@@ -2273,6 +2286,35 @@ typedef struct QemuOptions
int defconfig;
} QemuOptions;
+static void qemu_parse_option(int index, const char *optarg, QemuOptions
*options);
+
+static int qemu_parse_system_option(const char *name, const char *value, void
*opaque)
+{
+ QemuOptions *options = opaque;
+ const QEMUOption *popt;
+
+ popt = find_opt_by_name(name);
+ if (popt == NULL) {
+ return -1;
+ }
+
+ qemu_parse_option(popt->index, value, options);
+
+ return 0;
+}
+
+static int qemu_parse_system_section(QemuOpts *opts, void *opaque)
+{
+ QemuOptions *options = opaque;
+
+ return qemu_opt_foreach(opts, qemu_parse_system_option, options, 0);
+}
+
+static void qemu_parse_system_sections(QemuOptions *options)
+{
+ qemu_opts_foreach(qemu_find_opts("system"), qemu_parse_system_section,
options, 1);
+}
+
static void qemu_parse_option(int index, const char *optarg, QemuOptions
*options)
{
QemuOpts *opts;
@@ -3143,6 +3185,8 @@ static void qemu_parse_options(int argc, char **argv,
QemuOptions *options)
qemu_parse_option(popt->index, optarg, options);
}
}
+
+ qemu_parse_system_sections(options);
}
int main(int argc, char **argv, char **envp)
--
1.7.5.4
- [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Anthony Liguori, 2012/03/19
- [Qemu-devel] [PATCH 5/9] vl: enable system configuration to be used,
Anthony Liguori <=
- [Qemu-devel] [PATCH 1/9] qemu-config: fix -writeconfig when using qemu_opt_set_bool, Anthony Liguori, 2012/03/19
- [Qemu-devel] [PATCH 2/9] qemu-config: friends don't let friends use sscanf, Anthony Liguori, 2012/03/19
- [Qemu-devel] [PATCH 4/9] vl: mark system configuration options in qemu-options.hx, Anthony Liguori, 2012/03/19
- [Qemu-devel] [PATCH 3/9] vl: refactor command line parsing to allow options to be set via config, Anthony Liguori, 2012/03/19
- [Qemu-devel] [PATCH 7/9] qmp: expose a command to query capabilities of config parser, Anthony Liguori, 2012/03/19
[Qemu-devel] [PATCH 9/9] Add a management tool writer's guide, Anthony Liguori, 2012/03/19