[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 07/11] iotests: add qmp recursive sorting fun
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [Qemu-devel] [PATCH v5 07/11] iotests: add qmp recursive sorting function |
Date: |
Thu, 20 Dec 2018 09:42:38 +0000 |
20.12.2018 5:29, John Snow wrote:
> Python before 3.6 does not sort dictionaries (including kwargs).
> Therefore, printing QMP objects involves sorting the keys to have
> a predictable ordering in the iotests output.
>
> However, if we want to pretty-print QMP objects being sent to the
> QEMU process, we need to build the entire command before logging it.
> Ordinarily, this would then involve "arguments" being sorted above
> "execute", which would necessitate a rather ugly and harder-to-read
> change to many iotests outputs.
I'm unsure about what it means 'build the entire command before logging'.
[upd, after a second]
aha, it's about '{"execute":...' -> {'execute': ...}
may be, build the entire command object to be passed to json.dumps, or
like this would be better, if you want.
>
> To facilitate pretty-printing AND maintaining predictable output AND
> having "arguments" sort before "execute", add a custom sort function
> that takes a dictionary and recursively builds an OrderedDict that
> maintains the specific key order we wish to see in iotests output.
>
> Signed-off-by: John Snow<address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
--
Best regards,
Vladimir
- Re: [Qemu-devel] [PATCH v5 03/11] blockdev: n-ary bitmap merge, (continued)
- [Qemu-devel] [PATCH v5 04/11] block: remove 'x' prefix from experimental bitmap APIs, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 06/11] iotests: add filter_generated_node_ids, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 05/11] iotests.py: don't abort if IMGKEYSECRET is undefined, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 08/11] iotests: remove default filters from qmp_log, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 07/11] iotests: add qmp recursive sorting function, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 10/11] iotests: implement pretty-print for log and qmp_log, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 09/11] iotests: change qmp_log filters to expect QMP objects only, John Snow, 2018/12/19
- [Qemu-devel] [PATCH v5 11/11] iotests: add iotest 236 for testing bitmap merge, John Snow, 2018/12/19