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 <[email protected]> > --- > 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
