[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qmp: add support for mixed typed input visitor
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qmp: add support for mixed typed input visitor |
Date: |
Thu, 14 Jul 2016 08:23:18 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 07/14/2016 08:16 AM, Daniel P. Berrange wrote:
> Add a qmp_mixed_input_visitor_new() method which returns
> a QMP input visitor that accepts either strings or the
> native data types.
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>
> NB, just a demo - this should have tests added before submitting
> for real.
>
>
> +static void qmp_input_type_int64_mixed(Visitor *v, const char *name, int64_t
> *obj,
> + Error **errp)
> +{
> + QmpInputVisitor *qiv = to_qiv(v);
> + QObject *qobj = qmp_input_get_object(qiv, name, true);
This consumes the key out of the QDict input stream...
> +
> + if (qobj && qobj->type == QTYPE_QSTRING) {
> + qmp_input_type_int64_str(v, name, obj, errp);
then calls a helper function that also wants to consume the key. You'll
have to use qmp_input_get_object(,false) for this to work (in other
words, do a peek instead of consume when deciding which other helper to
use).
> +
> +Visitor *qmp_mixed_input_visitor_new(QObject *obj, bool strict)
> +{
I guess it's not too hard to generate 'qmp_mixed_input_visitor_new'
instead of 'qmp_input_visitor_new' when 'autocast':true is set in QAPI,
so that's a minor tweak to my series. Your version also has the benefit
of not changing all existing callers to add another parameter.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature