qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/11] qjson: Simplify by using json-output-visitor
Date: Fri, 11 Dec 2015 06:42:56 -0700	[thread overview]
Message-ID: <566AD2E0.90006@redhat.com> (raw)
In-Reply-To: <566AAF3A.8090902@redhat.com>

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

On 12/11/2015 04:10 AM, Paolo Bonzini wrote:
> 
> 
> On 11/12/2015 00:53, Eric Blake wrote:
>> Instead of rolling our own limited JSON outputter, we can just
>> wrap the more full-featured JSON output Visitor.
>>
>> This slightly changes the output (different spacing), but the
>> result is still equivalent JSON contents.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  qjson.c | 61 ++++++++++++++++++++++---------------------------------------
>>  1 file changed, 22 insertions(+), 39 deletions(-)
> 
> I didn't find out which tree your patches apply to, but this:

Mentioned in the cover letter:

+ v8 or later of my qapi subset E patches (at the time of this mail,
only v7 has been posted):
https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg01181.html

Also available as a tag at this location (with prerequisites applied):
git fetch git://repo.or.cz/qemu/ericb.git qapi-jsonv1

(note that it is only a tag, not a branch, and you are right that it
doesn't yet apply to any maintainer's tree).


> @@ -1068,9 +1070,11 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
>          return;
>      }
>  
> -    vmdesc = qjson_new();
> -    json_prop_int(vmdesc, "page_size", TARGET_PAGE_SIZE);
> -    json_start_array(vmdesc, "devices");
> +    vmdesc_jov = json_output_visitor_new();
> +    vmdesc = json_output_get_visitor(vmdesc_jov);
> +    visit_start_struct(vmdesc, NULL, 0, NULL, &error_abort);
> +    visit_type_int(vmdesc, TARGET_PAGE_SIZE, "page_size", &error_abort);
> +    visit_start_list(vmdesc, NULL, 0, "devices", &error_abort);
>      QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {

Nice idea.

> compiles and is pretty much a 1:1 translation from the qjson.c API to the
> visitor API (using this patch as a guide).  Feel free to include it and
> remove qjson.c.  Alternatively, you can leave out this patch and I'll test
> and submit the transition.

Should I squash the two together, or keep my current patch and drop
qjson.c as a separate patch?

Also, while reading this, I noticed that qjson.h has signatures that
match JSON ('name' comes before 'value', when generating a "name":value
pair), while visitor.h has signatures that are backwards ('obj' comes
before 'name', even though the output will be "name":value-of-obj).  I'm
seriously debating about a tree-wide coccinelle patch to reverse the
order or arguments of all the visit_type_* functions.

-- 
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:[~2015-12-11 13:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 23:53 [Qemu-devel] [RFC PATCH 00/11] Add qapi-to-JSON output visitor Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 01/11] qapi: Rename qjson.h to qobject-json.h Eric Blake
2015-12-11 11:00   ` Paolo Bonzini
2015-12-10 23:53 ` [Qemu-devel] [PATCH 02/11] qapi: Improve use of qmp/types.h Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 03/11] qapi: Factor out JSON string escaping Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 04/11] qapi: Factor out JSON number formatting Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 05/11] qapi: Use qstring_append_chr() where appropriate Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 06/11] qapi: Add qstring_append_format() Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 07/11] qapi: add json output visitor Eric Blake
2015-12-11  0:24   ` Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 08/11] qjson: Simplify by using json-output-visitor Eric Blake
2015-12-11 11:10   ` Paolo Bonzini
2015-12-11 13:42     ` Eric Blake [this message]
2015-12-11 13:45       ` Paolo Bonzini
2015-12-18 23:06     ` Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 09/11] qapi: Add qobject_to_json_pretty_prefix() Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 10/11] qapi: Support pretty printing in JSON output visitor Eric Blake
2015-12-10 23:53 ` [Qemu-devel] [PATCH 11/11] RFC: qemu-img: Use new JSON output formatter Eric Blake
2015-12-11  1:36   ` Fam Zheng

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=566AD2E0.90006@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@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).