]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qmp-shell: Sort by key when pretty-printing
authorDavid Edmondson <david.edmondson@oracle.com>
Tue, 13 Oct 2020 14:14:14 +0000 (15:14 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 27 Oct 2020 10:11:06 +0000 (11:11 +0100)
If the user selects pretty-printing (-p) the contents of any
dictionaries in the output are sorted by key.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
Message-Id: <20201013141414.18398-1-david.edmondson@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qmp/qmp-shell

index c5eef06f3fd99641f019b3f39e05131035ad435b..b4d06096abd61151fe9e19285d969fcdf74a8fff 100755 (executable)
@@ -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):