From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Jeff Cody <jcody@redhat.com>,
Peter Lieven <pl@kamp.de>, Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 14/15] qemu-img: Use QAPI visitor to generate JSON
Date: Thu, 10 Dec 2015 15:09:23 -0700 [thread overview]
Message-ID: <5669F813.2080105@redhat.com> (raw)
In-Reply-To: <1448514335-15988-15-git-send-email-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3322 bytes --]
On 11/25/2015 10:05 PM, Fam Zheng wrote:
> A visible improvement is that "filename" is now included in the output
> if it's valid.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> qemu-img.c | 34 ++++++++++------
> tests/qemu-iotests/122.out | 96 ++++++++++++++++++++++++++--------------------
> 2 files changed, 77 insertions(+), 53 deletions(-)
>
> @@ -2157,20 +2163,26 @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e,
> }
> break;
> case OFORMAT_JSON:
> - printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64","
The space after '{' here is interesting below [1]
> - " \"depth\": %"PRId64", \"zero\": %s, \"data\": %s",
> - (e->start == 0 ? "[" : ",\n"),
> - e->start, e->length, e->depth,
> - e->zero ? "true" : "false",
> - e->data ? "true" : "false");
> - if (e->has_offset) {
> - printf(", \"offset\": %"PRId64"", e->offset);
> - }
> - putchar('}');
> + ov = qmp_output_visitor_new();
> + visit_type_MapEntry(qmp_output_get_visitor(ov),
> + &e, NULL, &error_abort);
> + obj = qmp_output_get_qobject(ov);
> + str = qobject_to_json(obj);
> + assert(str != NULL);
For what it's worth, I have a patch series on my local tree that adds
json_output_visitor_new(), and which would not only bypass the wasted
QObject by doing a multi-step qapi=>QObject=>JSON, but it also has the
benefit of outputting JSON that is in qapi order (under your control)
rather than QDict hash order (deterministic and still valid JSON, but
hard to predict and not always the nicest results for human readers).
> +++ b/tests/qemu-iotests/122.out
> @@ -49,12 +49,13 @@ read 65536/65536 bytes at offset 4194304
> 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> read 65536/65536 bytes at offset 8388608
> 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -[{ "start": 0, "length": 65536, "depth": 0, "zero": false, "data": true},
> -{ "start": 65536, "length": 4128768, "depth": 0, "zero": true, "data": false},
> -{ "start": 4194304, "length": 65536, "depth": 0, "zero": false, "data": true},
> -{ "start": 4259840, "length": 4128768, "depth": 0, "zero": true, "data": false},
> -{ "start": 8388608, "length": 65536, "depth": 0, "zero": false, "data": true},
> -{ "start": 8454144, "length": 4128768, "depth": 0, "zero": true, "data": false}]
> +[{"length": 65536, "start": 0, "zero": false, "depth": 0, "data": true}
Thus, my series conflicts with your patch, and one of us will have to
rebase on the other. But with my series, we'd have yet more churn here,
looking like:
> {"start": 65536, "length": 4128768, "data": true, "zero": true, "depth": 0},
unless we change patch 13/15 to lay out the qapi struct in the same
order as the existing output. But some churn is inevitable; both the
QObject formatter and my pending patches output a leading "{KEY", rather
than "{ KEY" (back to point [1] above), regardless of which key gets
displayed first.
--
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 --]
next prev parent reply other threads:[~2015-12-10 22:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 5:05 [Qemu-devel] [PATCH v3 00/15] qemu-img map: Allow driver to return file of the allocated block Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 01/15] block: Add "file" output parameter to block status query functions Fam Zheng
2015-11-30 8:38 ` Stefan Hajnoczi
2015-11-30 9:09 ` Fam Zheng
2015-12-01 9:25 ` Stefan Hajnoczi
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 02/15] qcow: Assign bs->file->bs to file in qcow_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 03/15] qcow2: Assign bs->file->bs to file in qcow2_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 04/15] raw: Assign bs to file in raw_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 05/15] iscsi: Assign bs to file in iscsi_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 06/15] parallels: Assign bs->file->bs to file in parallels_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 07/15] qed: Assign bs->file->bs to file in bdrv_qed_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 08/15] sheepdog: Assign bs to file in sd_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 09/15] vdi: Assign bs->file->bs to file in vdi_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 10/15] vpc: Assign bs->file->bs to file in vpc_co_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 11/15] vmdk: Return extent's file in bdrv_get_block_status Fam Zheng
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 12/15] qemu-img: In "map", use the returned "file" from bdrv_get_block_status Fam Zheng
2015-11-26 5:21 ` Eric Blake
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 13/15] qemu-img: Make MapEntry a QAPI struct Fam Zheng
2015-11-26 5:19 ` Eric Blake
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 14/15] qemu-img: Use QAPI visitor to generate JSON Fam Zheng
2015-12-10 22:09 ` Eric Blake [this message]
2015-11-26 5:05 ` [Qemu-devel] [PATCH v3 15/15] iotests: Add "qemu-img map" test for VMDK extents Fam Zheng
2015-11-30 8:43 ` [Qemu-devel] [PATCH v3 00/15] qemu-img map: Allow driver to return file of the allocated block Stefan Hajnoczi
2015-12-01 9:25 ` Stefan Hajnoczi
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=5669F813.2080105@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).