qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH v14 14/21] qapi: allow repeated opts with qobject_in


From: Daniel P. Berrange
Subject: [Qemu-block] [PATCH v14 14/21] qapi: allow repeated opts with qobject_input_visitor_new_opts
Date: Fri, 30 Sep 2016 15:45:37 +0100

The qobject_input_visitor_new_opts() method gains a new
parameter to control whether it allows repeated option
keys in the input QemuOpts or not.

Signed-off-by: Daniel P. Berrange <address@hidden>
---
 include/qapi/qobject-input-visitor.h | 6 ++++++
 qapi/qobject-input-visitor.c         | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/qapi/qobject-input-visitor.h 
b/include/qapi/qobject-input-visitor.h
index 242b767..bc5062a 100644
--- a/include/qapi/qobject-input-visitor.h
+++ b/include/qapi/qobject-input-visitor.h
@@ -112,6 +112,11 @@ Visitor *qobject_input_visitor_new_autocast(QObject *obj,
  * qobject_input_visitor_new_autocast() method. See the docs
  * of that method for further details on processing behaviour.
  *
+ * If the @permit_repeated_opts parameter is true, then the input
+ * @opts is allowed to contain repeated keys and they will be
+ * turned into a QList. If it is false, then repeated keys will
+ * result in an error being reported.
+ *
  * The returned input visitor should be released by calling
  * visit_free() when no longer required.
  */
@@ -119,6 +124,7 @@ Visitor *qobject_input_visitor_new_opts(const QemuOpts 
*opts,
                                         bool autocreate_list,
                                         size_t autocreate_struct_levels,
                                         bool permit_int_ranges,
+                                        bool permit_repeated_opts,
                                         Error **errp);
 
 #endif
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 2287d11..5a3872c 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -753,6 +753,7 @@ Visitor *qobject_input_visitor_new_opts(const QemuOpts 
*opts,
                                         bool autocreate_list,
                                         size_t autocreate_struct_levels,
                                         bool permit_int_ranges,
+                                        bool permit_repeated_opts,
                                         Error **errp)
 {
     QDict *pdict;
@@ -760,7 +761,9 @@ Visitor *qobject_input_visitor_new_opts(const QemuOpts 
*opts,
     Visitor *v = NULL;
 
     pdict = qemu_opts_to_qdict(opts, NULL,
-                               QEMU_OPTS_REPEAT_POLICY_LAST,
+                               permit_repeated_opts ?
+                               QEMU_OPTS_REPEAT_POLICY_ALL :
+                               QEMU_OPTS_REPEAT_POLICY_ERROR,
                                errp);
     if (!pdict) {
         goto cleanup;
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]