]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu-replies-tool: Dump 'qom-list-types'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 4 Jan 2024 12:22:34 +0000 (13:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 1 Feb 2024 09:55:01 +0000 (10:55 +0100)
The order of entries in 'qom-list-types' sometimes changes arbitrarily.

The --dump-qom-list-types produces a stable order and drops the for
libvirt unneeded 'parent' information.

Sample output:

$ ./scripts/qemu-replies-tool.py tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies --dump-qom-list-types
(qom) 486-v1-x86_64-cpu
(qom) 486-x86_64-cpu
(qom) AC97
(qom) AMDVI-PCI
(qom) Broadwell-IBRS-x86_64-cpu
(qom) Broadwell-noTSX-IBRS-x86_64-cpu
(qom) Broadwell-noTSX-x86_64-cpu
(qom) Broadwell-v1-x86_64-cpu
(qom) Broadwell-v2-x86_64-cpu
(qom) Broadwell-v3-x86_64-cpu

[...]

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
scripts/qemu-replies-tool.py

index 4e5ce3fdf3cb9ea220ed93a9b0826c8bde23bfc4..11aa56ad7ab8b3a65baf043fcd2fd993484f306f 100755 (executable)
@@ -382,6 +382,28 @@ def dump_qmp_probe_strings(schemalist):
         dump_qmp_probe_strings_iter(c, '(qmp) ' + c, [], schemadict)
 
 
+def dump_qom_list_types(conv):
+    types = []
+
+    for (cmd, rep) in conv:
+        if cmd['execute'] == 'qom-list-types':
+            for qomtype in rep['return']:
+                # validate known fields:
+                # 'parent' is ignored below as it causes output churn
+                for k in qomtype:
+                    if k not in ['name', 'parent']:
+                        raise Exception("Unhandled 'qom-list-types' field '%s'" % k)
+
+                types.append(qomtype['name'])
+
+            break
+
+    types.sort()
+
+    for t in types:
+        print('(qom) ' + t)
+
+
 def process_one(filename, args):
     try:
         conv = qemu_replies_load(filename)
@@ -397,6 +419,10 @@ def process_one(filename, args):
                     dump_qmp_probe_strings(rep['return'])
                     dumped = True
 
+        if args.dump_all or args.dump_qom_list_types:
+            dump_qom_list_types(conv)
+            dumped = True
+
         if dumped:
             return True
 
@@ -441,6 +467,11 @@ functional impact on libvirt.
     virQEMUCapsQMPSchemaQueries. It's useful to find specific query string
     without having to piece the information together from 'query-qmp-schema'
 
+  --dump-qom-list-types
+
+    Dumps all types returned by 'qom-list-types' in a stable order with the
+    'parent' property dropped as it's not relevant for libvirt.
+
 The tool can be also used to programmaticaly modify the '.replies' file by
 editing the 'modify_replies' method directly in the source, or for
 re-formatting and re-numbering the '.replies' file to conform with the required
@@ -471,6 +502,9 @@ parser.add_argument('--dump-all', action='store_true',
 parser.add_argument('--dump-qmp-query-strings', action='store_true',
                     help='dump QMP schema in form of query strings used to probe capabilities')
 
+parser.add_argument('--dump-qom-list-types', action='store_true',
+                    help='dump data from qom-list-types in a stable order')
+
 args = parser.parse_args()
 
 files = []