On 1/30/19 8:26 PM, John Snow wrote: > It's not enough to order the kwargs for consistent QMP log output, > we must also sort any sub-dictionaries in lists that appear as values. > > Reported-by: Kevin Wolf <[email protected]> > Signed-off-by: John Snow <[email protected]> > --- > tests/qemu-iotests/236.out | 56 +++++++++++++++++------------------ > tests/qemu-iotests/iotests.py | 21 ++++++------- > 2 files changed, 39 insertions(+), 38 deletions(-) >
> +++ b/tests/qemu-iotests/iotests.py
> @@ -76,15 +76,16 @@ def qemu_img(*args):
> sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, '
> '.join(qemu_img_args + list(args))))
> return exitcode
>
> -def ordered_kwargs(kwargs):
> - # kwargs prior to 3.6 are not ordered, so:
> - od = OrderedDict()
> - for k, v in sorted(kwargs.items()):
> - if isinstance(v, dict):
> - od[k] = ordered_kwargs(v)
> - else:
> - od[k] = v
> - return od
> +def ordered_qmp(qmsg):
> + # Dictionaries are not ordered prior to 3.6, therefore:
> + if isinstance(qmsg, list):
> + return [ordered_qmp(atom) for atom in qmsg]
> + if isinstance(qmsg, dict):
> + od = OrderedDict()
> + for k, v in sorted(qmsg.items()):
> + od[k] = ordered_qmp(v)
> + return od
> + return qmsg
>
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
