qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qmp: add support for mixed typed input visitor
Date: Thu, 14 Jul 2016 08:23:18 -0600	[thread overview]
Message-ID: <5787A056.5090705@redhat.com> (raw)
In-Reply-To: <1468505770-20694-1-git-send-email-berrange@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]

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 <berrange@redhat.com>
> ---
> 
> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-07-14 14:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 14:16 [Qemu-devel] [PATCH] qmp: add support for mixed typed input visitor Daniel P. Berrange
2016-07-14 14:23 ` Eric Blake [this message]
2016-07-14 14:39   ` Daniel P. Berrange
2016-07-14 16:28     ` Eric Blake
2016-07-15 12:48       ` Markus Armbruster
2016-07-20  9:02         ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5787A056.5090705@redhat.com \
    --to=eblake@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).