]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
scripts: qemu-replies-tool: List also data from 'qom-list-properties'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Aug 2025 14:41:36 +0000 (16:41 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Sep 2025 08:55:24 +0000 (10:55 +0200)
In addition to 'device-list-properties' libvirt probes also some
properties of qom types. Since the format is identical make the dumping
function for 'device-list-properties' universal and make it accept also
'qom-list-types'.

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

index 211c4484826fae47f4d4f4f57ed88465b04cb1da..77d96f625d3042b9512d83125a72e1371d9d2df8 100755 (executable)
@@ -409,30 +409,40 @@ def dump_qom_list_types(conv):
         print('(qom) ' + t)
 
 
-def dump_device_list_properties(conv):
-    devices = []
+def dump_device_and_object_properties(conv):
+    ent = []
 
     for c in conv:
+        prefix = None
+
         if c['cmd']['execute'] == 'device-list-properties':
-            if 'return' in c['rep']:
-                for arg in c['rep']['return']:
-                    for k in arg:
-                        if k not in ['name', 'type', 'description', 'default-value']:
-                            raise Exception("Unhandled 'device-list-properties' typename '%s' field '%s'" % (c['cmd']['arguments']['typename'], k))
-
-                    if 'default-value' in arg:
-                        defval = ' (%s)' % str(arg['default-value'])
-                    else:
-                        defval = ''
+            prefix = '(dev-prop)'
+
+        if c['cmd']['execute'] == 'qom-list-properties':
+            prefix = '(qom-prop)'
+
+        if prefix is None or 'return' not in c['rep']:
+            continue
+
+        for arg in c['rep']['return']:
+            for k in arg:
+                if k not in ['name', 'type', 'description', 'default-value']:
+                    raise Exception("Unhandled 'device-list-properties'/'qom-list-properties' typename '%s' field '%s'" % (c['cmd']['arguments']['typename'], k))
+
+                if 'default-value' in arg:
+                    defval = ' (%s)' % str(arg['default-value'])
+                else:
+                    defval = ''
 
-                    devices.append('%s %s %s%s' % (c['cmd']['arguments']['typename'],
-                                                   arg['name'],
-                                                   arg['type'],
-                                                   defval))
-    devices.sort()
+                    ent.append('%s %s %s %s%s' % (prefix,
+                                                  c['cmd']['arguments']['typename'],
+                                                  arg['name'],
+                                                  arg['type'],
+                                                  defval))
+    ent.sort()
 
-    for d in devices:
-        print('(dev) ' + d)
+    for e in ent:
+        print(e)
 
 
 # Sort helper for version string e.g. '11.0', '1.2' etc. Tolerates empty version.
@@ -507,7 +517,7 @@ def process_one(filename, args):
 
         if args.dump_all:
             dump_qom_list_types(conv)
-            dump_device_list_properties(conv)
+            dump_device_and_object_properties(conv)
             dump_machine_types(conv)
             dumped = True