From: David Edmondson Date: Tue, 13 Oct 2020 14:14:14 +0000 (+0100) Subject: qmp-shell: Sort by key when pretty-printing X-Git-Tag: v5.2.0-rc0~22^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fca9d723232a8bc756ca74982ee342f73ebf833c;p=thirdparty%2Fqemu.git qmp-shell: Sort by key when pretty-printing If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key. Signed-off-by: David Edmondson Message-Id: <20201013141414.18398-1-david.edmondson@oracle.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Markus Armbruster --- diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index c5eef06f3fd..b4d06096abd 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline):