[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 6/6] block: convert to use qapi_stringify_Ima
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v1 6/6] block: convert to use qapi_stringify_ImageInfoSpecific |
Date: |
Tue, 7 Jun 2016 10:59:49 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 06/07/2016 04:11 AM, Daniel P. Berrange wrote:
> When 'qemu-img info' prints out format specific information,
> it first converts the QAPI object into a JSON based QObject
> data structure. Unfortunately structs have to be turned into
> dicts, which looses all information about field ordering,
s/looses/loses/
> so the data printed appears in a semi-random order.
>
> Convert this to use the qapi_stringify_ImageInfoSpecific()
> which uses a visitor to directly pretty-print the objects
> without the intermediate QObject conversion, and thus will
> maintain struct field ordering.
>
The idea makes sense. I'm not sure we want to go all the way to
qapi_stringify_ImageInfoSpecific(), vs. just having a nice accessor
macro that takes care of type-punning through a common actor (the way I
did it in my series for QAPI_CLONE()).
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
> block/qapi.c | 101
> ++---------------------------------------------------------
> 1 file changed, 3 insertions(+), 98 deletions(-)
>
> @@ -599,107 +598,13 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf,
> void *f,
> }
> }
>
> -static void dump_qdict(fprintf_function func_fprintf, void *f, int
> indentation,
> - QDict *dict);
> -static void dump_qlist(fprintf_function func_fprintf, void *f, int
> indentation,
> - QList *list);
> -
> -static void dump_qobject(fprintf_function func_fprintf, void *f,
> - int comp_indent, QObject *obj)
> -{
> - switch (qobject_type(obj)) {
> - case QTYPE_QINT: {
> - QInt *value = qobject_to_qint(obj);
> - func_fprintf(f, "%" PRId64, qint_get_int(value));
> - break;
It's also nice that we're moving some of this code into a more
general-purpose visitor.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v1 2/6] block: export LUKS specific data to qemu-img info, (continued)
[Qemu-devel] [PATCH v1 4/6] qapi: add a text output visitor for pretty printing types, Daniel P. Berrange, 2016/06/07
[Qemu-devel] [PATCH v1 5/6] qapi: generate a qapi_stringify_TYPENAME method for all types, Daniel P. Berrange, 2016/06/07
[Qemu-devel] [PATCH v1 6/6] block: convert to use qapi_stringify_ImageInfoSpecific, Daniel P. Berrange, 2016/06/07
- Re: [Qemu-devel] [PATCH v1 6/6] block: convert to use qapi_stringify_ImageInfoSpecific,
Eric Blake <=
Re: [Qemu-devel] [PATCH v1 0/6] Report format specific info for LUKS block driver, Eric Blake, 2016/06/07
Re: [Qemu-devel] [PATCH v1 0/6] Report format specific info for LUKS block driver, Max Reitz, 2016/06/14