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 <alistair.fran...@xilinx.com> --- 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