From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpz5G-0004L1-QD for qemu-devel@nongnu.org; Fri, 30 Sep 2016 10:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpz5C-0003Dj-PJ for qemu-devel@nongnu.org; Fri, 30 Sep 2016 10:46:42 -0400 From: "Daniel P. Berrange" Date: Fri, 30 Sep 2016 15:45:37 +0100 Message-Id: <1475246744-29302-15-git-send-email-berrange@redhat.com> In-Reply-To: <1475246744-29302-1-git-send-email-berrange@redhat.com> References: <1475246744-29302-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v14 14/21] qapi: allow repeated opts with qobject_input_visitor_new_opts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Eric Blake , "Daniel P. Berrange" 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 --- 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