[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/4] qemu-option.c: Add qemu_opt functions that s
From: |
Alistair Francis |
Subject: |
[Qemu-devel] [PATCH v2 1/4] qemu-option.c: Add qemu_opt functions that step over arguments |
Date: |
Fri, 11 Apr 2014 16:34:44 +1000 |
This adds two functions, qemu_opt_step() and qemu_opt_name_step()
which iterate over the comma separated stings in the QemuOpts*
argument. This allows accessing multiple arguments with the
same name by iterating over all of the arguments
Signed-off-by: Alistair Francis <address@hidden>
---
include/qemu/option.h | 2 ++
util/qemu-option.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 8c0ac34..ad20cd4 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -110,6 +110,8 @@ struct QemuOptsList {
};
const char *qemu_opt_get(QemuOpts *opts, const char *name);
+const char *qemu_opt_name_step(QemuOpts *opts, int num);
+const char *qemu_opt_step(QemuOpts *opts, int num);
/**
* qemu_opt_has_help_opt:
* @opts: options to search for a help request
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 9d898af..4192c13 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -541,6 +541,36 @@ void print_option_help(QEMUOptionParameter *list)
/* ------------------------------------------------------------------ */
+const char *qemu_opt_name_step(QemuOpts *opts, int num)
+{
+ QemuOpt *opt;
+ int i = 0;
+
+ QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+ if (i < num) {
+ i++;
+ continue;
+ }
+ return opt->name;
+ }
+ return NULL;
+}
+
+const char *qemu_opt_step(QemuOpts *opts, int num)
+{
+ QemuOpt *opt;
+ int i = 0;
+
+ QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+ if (i < num) {
+ i++;
+ continue;
+ }
+ return opt->str;
+ }
+ return NULL;
+}
+
static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
{
QemuOpt *opt;
--
1.7.1
- [Qemu-devel] [PATCH v2 0/4] Allow sysbus devices to be attached via commandline, Alistair Francis, 2014/04/11
- [Qemu-devel] [PATCH v2 1/4] qemu-option.c: Add qemu_opt functions that step over arguments,
Alistair Francis <=
- [Qemu-devel] [PATCH v2 2/4] qdev-monitor: Implement three functions used to connect devices, Alistair Francis, 2014/04/11
- [Qemu-devel] [PATCH v2 3/4] vl.c: Enable adding devices to the system bus, Alistair Francis, 2014/04/11
- [Qemu-devel] [PATCH v2 4/4] qemu-options.hx: Update the command line documentation for -device, Alistair Francis, 2014/04/11
- Re: [Qemu-devel] [PATCH v2 0/4] Allow sysbus devices to be attached via commandline, Alistair Francis, 2014/04/11
- Re: [Qemu-devel] [PATCH v2 0/4] Allow sysbus devices to be attached via commandline, Peter Maydell, 2014/04/11