Patchwork [11/13] qemu-option: New qemu_opt_next(), qemu_opt_name()

login
register
mail settings
Submitter Markus Armbruster
Date June 2, 2010, 4:55 p.m.
Message ID <1275497729-13120-12-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/54393/
State New
Headers show

Comments

Markus Armbruster - June 2, 2010, 4:55 p.m.
This is a more flexible alternative to qemu_opt_foreach().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-option.c |   13 +++++++++++++
 qemu-option.h |    4 ++++
 2 files changed, 17 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-option.c b/qemu-option.c
index 87e324c..c9f8be4 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -642,6 +642,19 @@  int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)
     return 0;
 }
 
+QemuOpt *qemu_opt_next(QemuOpts *opts, QemuOpt *opt)
+{
+    if (!opt) {
+        return QTAILQ_FIRST(&opts->head);
+    }
+    return QTAILQ_NEXT(opt, next);
+}
+
+const char *qemu_opt_name(QemuOpt *opt)
+{
+    return opt->name;
+}
+
 int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
                      int abort_on_failure)
 {
diff --git a/qemu-option.h b/qemu-option.h
index 9e2406c..13c6a9d 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -109,6 +109,10 @@  int qemu_opt_get_bool(QemuOpts *opts, const char *name, int defval);
 uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);
 uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval);
 int qemu_opt_set(QemuOpts *opts, const char *name, const char *value);
+
+QemuOpt *qemu_opt_next(QemuOpts *opts, QemuOpt *opt);
+const char *qemu_opt_name(QemuOpt *opt);
+
 typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque);
 int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
                      int abort_on_failure);