qemu-devel
[Top][All Lists]
Advanced

[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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]