All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection
@ 2026-10-09 14:04 Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type Markus Armbruster
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

Marc-André Lureau has patches to improve QOM introspection.  Latest
version is

    Subject: [PATCH v5 00/62] qom/qdev: associate properties with QAPI schema types 
    Date: Fri, 11 Sep 2026 20:34:34 +0400
    Message-Id: <20260911-qom-qapi-v5-0-7732a55b7760@redhat.com>
    https://lore.kernel.org/qemu-devel/20260911-qom-qapi-v5-0-7732a55b7760@redhat.com/

The first few patches make the QAPI code generator emit type
information for use by QOM introspection commands.  They refactor code
to gain access to masked type names, and to make query-qmp-schema not
elide types QOM introspection might want to refer to.

My series does this in a different way I find simpler.  It is RFC
because merging it only makes sense if Marc-André finds it useful.
Marc-André, please have a look.

Markus Armbruster (6):
  qapi/schema: Rename .lookup_entity() and tighten return type
  qapi: Ease access to introspection names
  qapi/introspect: Simplify masked name comment emission slighly
  qapi/introspect: Don't elide types
  qapi: QAPISchemaVisitor.visit_needed() is now unused, drop
  qapi/introspect: Tweak integer type masking

 docs/sphinx/qapidoc.py     |  2 +-
 scripts/qapi/introspect.py | 74 ++++++++++----------------------------
 scripts/qapi/schema.py     | 57 +++++++++++++++++++++++------
 3 files changed, 67 insertions(+), 66 deletions(-)

-- 
2.55.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 2/6] qapi: Ease access to introspection names Markus Armbruster
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

Commit 060b5a9323 (qapi: Dumb down QAPISchema.lookup_entity())
accidentally relaxed QAPISchema.lookup_entity()'s return type to
QAPISchemaEntity.  Tighten it back to QAPISchemaDefinition, and rename
the method to .lookup_defn().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/sphinx/qapidoc.py | 2 +-
 scripts/qapi/schema.py | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 54a32e45f7..31d09ed634 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -512,7 +512,7 @@ def transmogrify(self, schema: QAPISchema) -> nodes.Element:
                 modules.add(module_source)
 
             if doc.symbol:
-                ent = schema.lookup_entity(doc.symbol)
+                ent = schema.lookup_defn(doc.symbol)
                 assert isinstance(ent, QAPISchemaDefinition)
                 vis.visit_entity(ent)
             else:
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 8d88b40de2..9c9e257a8f 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -1184,11 +1184,11 @@ def _def_definition(self, defn: QAPISchemaDefinition) -> None:
                 defn.info, "%s is already defined" % other_defn.describe())
         self._entity_dict[defn.name] = defn
 
-    def lookup_entity(self, name: str) -> Optional[QAPISchemaEntity]:
+    def lookup_defn(self, name: str) -> Optional[QAPISchemaDefinition]:
         return self._entity_dict.get(name)
 
     def lookup_type(self, name: str) -> Optional[QAPISchemaType]:
-        typ = self.lookup_entity(name)
+        typ = self.lookup_defn(name)
         if isinstance(typ, QAPISchemaType):
             return typ
         return None
@@ -1324,7 +1324,7 @@ def _make_implicit_object_type(
             return None
         # See also QAPISchemaObjectTypeMember.describe()
         name = 'q_obj_%s-%s' % (name, role)
-        typ = self.lookup_entity(name)
+        typ = self.lookup_defn(name)
         if typ:
             assert isinstance(typ, QAPISchemaObjectType)
             # The implicit object type has multiple users.  This can
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 2/6] qapi: Ease access to introspection names
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 3/6] qapi/introspect: Simplify masked name comment emission slighly Markus Armbruster
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

query-qmp-schema masks type names, because they are not part of the
external interface.  Marc-André Lureau would like to also use them
with qom-list & friends.  Trouble is the masked names are buried deep
in QAPISchemaGenIntrospectVisitor.  Lift them into schema.py: new
QAPISchemaDefinition method introspection_name() returns a
definition's name for use in introspection.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/introspect.py | 23 ++++----------------
 scripts/qapi/schema.py     | 43 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 19 deletions(-)

diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
index 7e28de2279..644461560c 100644
--- a/scripts/qapi/introspect.py
+++ b/scripts/qapi/introspect.py
@@ -30,7 +30,6 @@
     QAPISchemaAlternatives,
     QAPISchemaArrayType,
     QAPISchemaBranches,
-    QAPISchemaBuiltinType,
     QAPISchemaEntity,
     QAPISchemaEnumMember,
     QAPISchemaFeature,
@@ -177,7 +176,6 @@ def __init__(self, prefix: str, unmask: bool):
         self._schema: Optional[QAPISchema] = None
         self._trees: List[Annotated[SchemaInfo]] = []
         self._used_types: List[QAPISchemaType] = []
-        self._name_map: Dict[str, str] = {}
         self._genc.add(mcgen('''
 #include "qemu/osdep.h"
 #include "%(prefix)sqapi-introspect.h"
@@ -208,18 +206,14 @@ def visit_end(self) -> None:
         self._schema = None
         self._trees = []
         self._used_types = []
-        self._name_map = {}
 
     def visit_needed(self, entity: QAPISchemaEntity) -> bool:
         # Ignore types on first pass; visit_end() will pick up used types
         return not isinstance(entity, QAPISchemaType)
 
     def _name(self, name: str) -> str:
-        if self._unmask:
-            return name
-        if name not in self._name_map:
-            self._name_map[name] = '%d' % len(self._name_map)
-        return self._name_map[name]
+        assert self._schema
+        return self._schema.definition_introspection_name(name, self._unmask)
 
     def _use_type(self, typ: QAPISchemaType) -> str:
         assert self._schema is not None
@@ -237,13 +231,6 @@ def _use_type(self, typ: QAPISchemaType) -> str:
         # Add type to work queue if new
         if typ not in self._used_types:
             self._used_types.append(typ)
-        # Clients should examine commands and events, not types.  Hide
-        # type names as integers to reduce the temptation.  Also, it
-        # saves a few characters on the wire.
-        if isinstance(typ, QAPISchemaBuiltinType):
-            return typ.name
-        if isinstance(typ, QAPISchemaArrayType):
-            return '[' + self._use_type(typ.element_type) + ']'
         return self._name(typ.name)
 
     @staticmethod
@@ -271,8 +258,7 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object],
                 # Output a comment to make it easy to map masked names
                 # back to the source when reading the generated output.
                 comment = f'"{self._name(name)}" = {name}'
-            name = self._name(name)
-        obj['name'] = name
+        obj['name'] = self._name(name)
         obj['meta-type'] = mtype
         if features:
             obj['features'] = self._gen_features(features)
@@ -327,8 +313,7 @@ def visit_array_type(self, name: str, info: Optional[QAPISourceInfo],
                          ifcond: QAPISchemaIfCond,
                          element_type: QAPISchemaType) -> None:
         element = self._use_type(element_type)
-        self._gen_tree('[' + element + ']', 'array', {'element-type': element},
-                       ifcond)
+        self._gen_tree(name, 'array', {'element-type': element}, ifcond)
 
     def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo],
                                ifcond: QAPISchemaIfCond,
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 9c9e257a8f..11f3accec8 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -136,6 +136,13 @@ def __repr__(self) -> str:
     def c_name(self) -> str:
         return c_name(self.name)
 
+    def set_ordinal(self, ordinal: int) -> None:
+        pass
+
+    # pylint: disable=unused-argument
+    def introspection_name(self, unmask: bool) -> str:
+        return self.name
+
     def check(self, schema: QAPISchema) -> None:
         assert not self._checked
         super().check(schema)
@@ -323,6 +330,17 @@ def visit(self, visitor: QAPISchemaVisitor) -> None:
 
 
 class QAPISchemaType(QAPISchemaDefinition, ABC):
+    def __init__(
+        self,
+        name: str,
+        info: Optional[QAPISourceInfo],
+        doc: Optional[QAPIDoc],
+        ifcond: Optional[QAPISchemaIfCond] = None,
+        features: Optional[List[QAPISchemaFeature]] = None,
+    ):
+        super().__init__(name, info, doc, ifcond, features)
+        self._masked_name: Optional[str] = None
+
     # Return the C type for common use.
     # For the types we commonly box, this is a pointer type.
     @abstractmethod
@@ -363,6 +381,17 @@ def need_has_if_optional(self) -> bool:
         # Except for arrays; see QAPISchemaArrayType.need_has_if_optional().
         return not self.c_type().endswith(POINTER_SUFFIX)
 
+    def set_ordinal(self, ordinal: int) -> None:
+        assert not self._masked_name
+        self._masked_name = str(ordinal)
+
+    def introspection_name(self, unmask: bool) -> str:
+        # Type names are not part of the external interface.  Hide
+        # them in introspection.  Also saves a few characters on the
+        # wire.
+        assert self._masked_name
+        return self.name if unmask else self._masked_name
+
     def check(self, schema: QAPISchema) -> None:
         super().check(schema)
         for feat in self.features:
@@ -402,6 +431,11 @@ def json_type(self) -> str:
     def doc_type(self) -> str:
         return self.json_type()
 
+    def introspection_name(self, unmask: bool):
+        if self.json_type() == 'int':
+            return 'int'
+        return self.name
+
     def visit(self, visitor: QAPISchemaVisitor) -> None:
         super().visit(visitor)
         visitor.visit_builtin_type(self.name, self.info, self.json_type())
@@ -503,6 +537,9 @@ def doc_type(self) -> Optional[str]:
             return None
         return 'array of ' + elt_doc_type
 
+    def introspection_name(self, unmask: bool):
+        return '[' + self.element_type.introspection_name(unmask) + ']'
+
     def visit(self, visitor: QAPISchemaVisitor) -> None:
         super().visit(visitor)
         visitor.visit_array_type(self.name, self.info, self.ifcond,
@@ -1182,6 +1219,7 @@ def _def_definition(self, defn: QAPISchemaDefinition) -> None:
                     "'%s' is already defined\n%s" % (defn.name, where))
             raise QAPISemError(
                 defn.info, "%s is already defined" % other_defn.describe())
+        defn.set_ordinal(len(self._entity_dict))
         self._entity_dict[defn.name] = defn
 
     def lookup_defn(self, name: str) -> Optional[QAPISchemaDefinition]:
@@ -1208,6 +1246,11 @@ def resolve_type(
                 info, "%s uses unknown type '%s'" % (what, name))
         return typ
 
+    def definition_introspection_name(self, name: str, unmask: bool) -> str:
+        defn = self.lookup_defn(name)
+        assert defn
+        return defn.introspection_name(unmask)
+
     def _module_name(self, fname: str) -> str:
         if QAPISchemaModule.is_system_module(fname):
             return fname
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 3/6] qapi/introspect: Simplify masked name comment emission slighly
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 2/6] qapi: Ease access to introspection names Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 4/6] qapi/introspect: Don't elide types Markus Armbruster
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

Instead of emitting the comment for certain meta-types, simply emit it
when introspection name and name differ.

This additionally emits it for arrays, which is fine.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/introspect.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
index 644461560c..49d1ed2897 100644
--- a/scripts/qapi/introspect.py
+++ b/scripts/qapi/introspect.py
@@ -253,12 +253,12 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object],
                          Will be omitted from the output if empty.
         """
         comment: Optional[str] = None
-        if mtype not in ('command', 'event', 'builtin', 'array'):
-            if not self._unmask:
-                # Output a comment to make it easy to map masked names
-                # back to the source when reading the generated output.
-                comment = f'"{self._name(name)}" = {name}'
-        obj['name'] = self._name(name)
+        introspection_name = self._name(name)
+        if introspection_name != name:
+            # Output a comment to make it easy to map masked names
+            # back to the source when reading the generated output.
+            comment = f'"{introspection_name}" = {name}'
+        obj['name'] = introspection_name
         obj['meta-type'] = mtype
         if features:
             obj['features'] = self._gen_features(features)
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 4/6] qapi/introspect: Don't elide types
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
                   ` (2 preceding siblings ...)
  2026-10-09 14:04 ` [RFC PATCH 3/6] qapi/introspect: Simplify masked name comment emission slighly Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 5/6] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop Markus Armbruster
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

query-qmp-schema elides types not reachable from commands and events.
It currently emits 1251 out of 1385 definitions, and elides 134 types.
Whether that's worthwhile is debatable.

Marc-André Lureau would like to make QOM introspection (qom-list &
friends) refer to QAPI types.  We additionally need types reachable
from QOM properties.

Unfortunately, the QAPI generator knows nothing about QOM properties.

We could manually mark the QAPI types to elide, or the QAPI types not
to elide even though they are not reachable from commands and events.
Feels very much not worthwhile to me.

We could conservatively approximate "reachable from QOM properties" by
"available for use with QOM properties".  These are the built-in and
user-defined types, and their arrays.  With that, we'd elide just 38
out of 1385 definitions.  Too few to be worthwhile.

Simply emit everything.

Output of query-qmp-schema grows from 247KiB to 274KiB for me.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/introspect.py | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
index 49d1ed2897..15302ecf15 100644
--- a/scripts/qapi/introspect.py
+++ b/scripts/qapi/introspect.py
@@ -28,9 +28,7 @@
 from .schema import (
     QAPISchema,
     QAPISchemaAlternatives,
-    QAPISchemaArrayType,
     QAPISchemaBranches,
-    QAPISchemaEntity,
     QAPISchemaEnumMember,
     QAPISchemaFeature,
     QAPISchemaIfCond,
@@ -175,7 +173,6 @@ def __init__(self, prefix: str, unmask: bool):
         self._unmask = unmask
         self._schema: Optional[QAPISchema] = None
         self._trees: List[Annotated[SchemaInfo]] = []
-        self._used_types: List[QAPISchemaType] = []
         self._genc.add(mcgen('''
 #include "qemu/osdep.h"
 #include "%(prefix)sqapi-introspect.h"
@@ -187,10 +184,6 @@ def visit_begin(self, schema: QAPISchema) -> None:
         self._schema = schema
 
     def visit_end(self) -> None:
-        # visit the types that are actually used
-        for typ in self._used_types:
-            typ.visit(self)
-        # generate C
         name = c_name(self._prefix, protect=False) + 'qmp_schema_qlit'
         self._genh.add(mcgen('''
 #include "qobject/qlit.h"
@@ -205,32 +198,12 @@ def visit_end(self) -> None:
                              c_string=_tree_to_qlit(self._trees)))
         self._schema = None
         self._trees = []
-        self._used_types = []
-
-    def visit_needed(self, entity: QAPISchemaEntity) -> bool:
-        # Ignore types on first pass; visit_end() will pick up used types
-        return not isinstance(entity, QAPISchemaType)
 
     def _name(self, name: str) -> str:
         assert self._schema
         return self._schema.definition_introspection_name(name, self._unmask)
 
     def _use_type(self, typ: QAPISchemaType) -> str:
-        assert self._schema is not None
-
-        # Map the various integer types to plain int
-        if typ.json_type() == 'int':
-            type_int = self._schema.lookup_type('int')
-            assert type_int
-            typ = type_int
-        elif (isinstance(typ, QAPISchemaArrayType) and
-              typ.element_type.json_type() == 'int'):
-            type_intlist = self._schema.lookup_type('intList')
-            assert type_intlist
-            typ = type_intlist
-        # Add type to work queue if new
-        if typ not in self._used_types:
-            self._used_types.append(typ)
         return self._name(typ.name)
 
     @staticmethod
@@ -295,6 +268,8 @@ def _gen_variant(self, variant: QAPISchemaVariant
 
     def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo],
                            json_type: str) -> None:
+        if json_type == 'int' and name != 'int':
+            return
         self._gen_tree(name, 'builtin', {'json-type': json_type})
 
     def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
@@ -312,6 +287,8 @@ def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
     def visit_array_type(self, name: str, info: Optional[QAPISourceInfo],
                          ifcond: QAPISchemaIfCond,
                          element_type: QAPISchemaType) -> None:
+        if element_type.json_type() == 'int' and name != 'intList':
+            return
         element = self._use_type(element_type)
         self._gen_tree(name, 'array', {'element-type': element}, ifcond)
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 5/6] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
                   ` (3 preceding siblings ...)
  2026-10-09 14:04 ` [RFC PATCH 4/6] qapi/introspect: Don't elide types Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:04 ` [RFC PATCH 6/6] qapi/introspect: Tweak integer type masking Markus Armbruster
  2026-10-09 14:57 ` [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Marc-André Lureau
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/schema.py | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 11f3accec8..9e2152fa41 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -179,11 +179,6 @@ def visit_end(self) -> None:
     def visit_module(self, name: str) -> None:
         pass
 
-    def visit_needed(self, entity: QAPISchemaEntity) -> bool:
-        # pylint: disable=unused-argument
-        # Default to visiting everything
-        return True
-
     def visit_include(self, name: str, info: Optional[QAPISourceInfo]) -> None:
         pass
 
@@ -315,8 +310,7 @@ def add_entity(self, ent: QAPISchemaEntity) -> None:
     def visit(self, visitor: QAPISchemaVisitor) -> None:
         visitor.visit_module(self.name)
         for entity in self._entity_list:
-            if visitor.visit_needed(entity):
-                entity.visit(visitor)
+            entity.visit(visitor)
 
 
 class QAPISchemaInclude(QAPISchemaEntity):
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC PATCH 6/6] qapi/introspect: Tweak integer type masking
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
                   ` (4 preceding siblings ...)
  2026-10-09 14:04 ` [RFC PATCH 5/6] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop Markus Armbruster
@ 2026-10-09 14:04 ` Markus Armbruster
  2026-10-09 14:57 ` [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Marc-André Lureau
  6 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2026-10-09 14:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, michael.roth, jsnow

Since introspection maps all integer types to 'int', we need to skip
all but one of them.  Instead of filtering by hardcoded name, filter
out duplicates.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/introspect.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
index 15302ecf15..dc6f70a6fe 100644
--- a/scripts/qapi/introspect.py
+++ b/scripts/qapi/introspect.py
@@ -172,7 +172,7 @@ def __init__(self, prefix: str, unmask: bool):
             ' * QAPI/QMP schema introspection', __doc__)
         self._unmask = unmask
         self._schema: Optional[QAPISchema] = None
-        self._trees: List[Annotated[SchemaInfo]] = []
+        self._trees: Dict[str, Annotated[SchemaInfo]] = {}
         self._genc.add(mcgen('''
 #include "qemu/osdep.h"
 #include "%(prefix)sqapi-introspect.h"
@@ -191,13 +191,14 @@ def visit_end(self) -> None:
 extern const QLitObject %(c_name)s;
 ''',
                              c_name=c_name(name)))
+        trees = list(self._trees.values())
         self._genc.add(mcgen('''
 const QLitObject %(c_name)s = %(c_string)s;
 ''',
                              c_name=c_name(name),
-                             c_string=_tree_to_qlit(self._trees)))
+                             c_string=_tree_to_qlit(trees)))
         self._schema = None
-        self._trees = []
+        self._trees = {}
 
     def _name(self, name: str) -> str:
         assert self._schema
@@ -235,7 +236,12 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object],
         obj['meta-type'] = mtype
         if features:
             obj['features'] = self._gen_features(features)
-        self._trees.append(Annotated(obj, ifcond, comment))
+        if introspection_name in self._trees:
+            # Duplicates are possible because
+            # QAPISchemaBuiltinType.introspection_name() returns 'int'
+            # for all integer types.  Ignore them.
+            return
+        self._trees[introspection_name] = Annotated(obj, ifcond, comment)
 
     def _gen_enum_member(self, member: QAPISchemaEnumMember
                          ) -> Annotated[SchemaInfoEnumMember]:
@@ -268,8 +274,6 @@ def _gen_variant(self, variant: QAPISchemaVariant
 
     def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo],
                            json_type: str) -> None:
-        if json_type == 'int' and name != 'int':
-            return
         self._gen_tree(name, 'builtin', {'json-type': json_type})
 
     def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
@@ -287,8 +291,6 @@ def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
     def visit_array_type(self, name: str, info: Optional[QAPISourceInfo],
                          ifcond: QAPISchemaIfCond,
                          element_type: QAPISchemaType) -> None:
-        if element_type.json_type() == 'int' and name != 'intList':
-            return
         element = self._use_type(element_type)
         self._gen_tree(name, 'array', {'element-type': element}, ifcond)
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection
  2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
                   ` (5 preceding siblings ...)
  2026-10-09 14:04 ` [RFC PATCH 6/6] qapi/introspect: Tweak integer type masking Markus Armbruster
@ 2026-10-09 14:57 ` Marc-André Lureau
  2026-10-13 13:57   ` Markus Armbruster
  6 siblings, 1 reply; 10+ messages in thread
From: Marc-André Lureau @ 2026-10-09 14:57 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, michael.roth, jsnow

Hi Markus

On Fri, Oct 9, 2026 at 6:05 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Marc-André Lureau has patches to improve QOM introspection.  Latest
> version is
>
>     Subject: [PATCH v5 00/62] qom/qdev: associate properties with QAPI schema types
>     Date: Fri, 11 Sep 2026 20:34:34 +0400
>     Message-Id: <20260911-qom-qapi-v5-0-7732a55b7760@redhat.com>
>     https://lore.kernel.org/qemu-devel/20260911-qom-qapi-v5-0-7732a55b7760@redhat.com/
>
> The first few patches make the QAPI code generator emit type
> information for use by QOM introspection commands.  They refactor code
> to gain access to masked type names, and to make query-qmp-schema not
> elide types QOM introspection might want to refer to.
>
> My series does this in a different way I find simpler.  It is RFC
> because merging it only makes sense if Marc-André finds it useful.
> Marc-André, please have a look.

This is essentially doing the same introspection changes but at a
different level. If you ask me, since it's essentially code cleanup at
this point, I would rather merge my changes first and iterate on top.
But you are the gate keeper, so I wouldn't hold it, we need to move
on... I can rebase on top of your refactoring if you prefer.


> Markus Armbruster (6):
>   qapi/schema: Rename .lookup_entity() and tighten return type
>   qapi: Ease access to introspection names
>   qapi/introspect: Simplify masked name comment emission slighly
>   qapi/introspect: Don't elide types
>   qapi: QAPISchemaVisitor.visit_needed() is now unused, drop
>   qapi/introspect: Tweak integer type masking
>
>  docs/sphinx/qapidoc.py     |  2 +-
>  scripts/qapi/introspect.py | 74 ++++++++++----------------------------
>  scripts/qapi/schema.py     | 57 +++++++++++++++++++++++------
>  3 files changed, 67 insertions(+), 66 deletions(-)
>
> --
> 2.55.0
>
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection
  2026-10-09 14:57 ` [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Marc-André Lureau
@ 2026-10-13 13:57   ` Markus Armbruster
  2026-10-13 15:20     ` Marc-André Lureau
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Armbruster @ 2026-10-13 13:57 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, michael.roth, jsnow

Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Hi Markus
>
> On Fri, Oct 9, 2026 at 6:05 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Marc-André Lureau has patches to improve QOM introspection.  Latest
>> version is
>>
>>     Subject: [PATCH v5 00/62] qom/qdev: associate properties with QAPI schema types
>>     Date: Fri, 11 Sep 2026 20:34:34 +0400
>>     Message-Id: <20260911-qom-qapi-v5-0-7732a55b7760@redhat.com>
>>     https://lore.kernel.org/qemu-devel/20260911-qom-qapi-v5-0-7732a55b7760@redhat.com/
>>
>> The first few patches make the QAPI code generator emit type
>> information for use by QOM introspection commands.  They refactor code
>> to gain access to masked type names, and to make query-qmp-schema not
>> elide types QOM introspection might want to refer to.
>>
>> My series does this in a different way I find simpler.  It is RFC
>> because merging it only makes sense if Marc-André finds it useful.
>> Marc-André, please have a look.
>
> This is essentially doing the same introspection changes but at a
> different level. If you ask me, since it's essentially code cleanup at
> this point, I would rather merge my changes first and iterate on top.
> But you are the gate keeper, so I wouldn't hold it, we need to move
> on... I can rebase on top of your refactoring if you prefer.

A rebase gives me a cleaner git history, which I like.  Asking you to do
it feels a bit unfair, so I did it:

    https://repo.or.cz/qemu/armbru.git/shortlog/refs/heads/qom-props-qapi-types-v5-rebased

I had to change "qapi: add type-infos generator" quite a bit (commit
465ae98da2).  Slightly simpler now.

I resolved a rebase conflict in "qom: convert scalar properties to
QAPI-aware registration".

I dropped "qapi: expose integer signedness and width in introspection"
because I don't agree with it, and couldn't be bothered to resolve the
conflict (iirc).

I dropped "qapi: select introspectable types directly", because it's not
needed anymore.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection
  2026-10-13 13:57   ` Markus Armbruster
@ 2026-10-13 15:20     ` Marc-André Lureau
  0 siblings, 0 replies; 10+ messages in thread
From: Marc-André Lureau @ 2026-10-13 15:20 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, michael.roth, jsnow

Hi

On Tue, Oct 13, 2026 at 5:57 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > Hi Markus
> >
> > On Fri, Oct 9, 2026 at 6:05 PM Markus Armbruster <armbru@redhat.com> wrote:
> >>
> >> Marc-André Lureau has patches to improve QOM introspection.  Latest
> >> version is
> >>
> >>     Subject: [PATCH v5 00/62] qom/qdev: associate properties with QAPI schema types
> >>     Date: Fri, 11 Sep 2026 20:34:34 +0400
> >>     Message-Id: <20260911-qom-qapi-v5-0-7732a55b7760@redhat.com>
> >>     https://lore.kernel.org/qemu-devel/20260911-qom-qapi-v5-0-7732a55b7760@redhat.com/
> >>
> >> The first few patches make the QAPI code generator emit type
> >> information for use by QOM introspection commands.  They refactor code
> >> to gain access to masked type names, and to make query-qmp-schema not
> >> elide types QOM introspection might want to refer to.
> >>
> >> My series does this in a different way I find simpler.  It is RFC
> >> because merging it only makes sense if Marc-André finds it useful.
> >> Marc-André, please have a look.
> >
> > This is essentially doing the same introspection changes but at a
> > different level. If you ask me, since it's essentially code cleanup at
> > this point, I would rather merge my changes first and iterate on top.
> > But you are the gate keeper, so I wouldn't hold it, we need to move
> > on... I can rebase on top of your refactoring if you prefer.
>
> A rebase gives me a cleaner git history, which I like.  Asking you to do
> it feels a bit unfair, so I did it:
>
>     https://repo.or.cz/qemu/armbru.git/shortlog/refs/heads/qom-props-qapi-types-v5-rebased

Awesome, I am happy with that! If you want to resubmit on ML or send
PR, up to you

I think the only local change I had (with the collected review
trailers), was BootCertificatesList conversion. But that can be a
follow up.

>
> I had to change "qapi: add type-infos generator" quite a bit (commit
> 465ae98da2).  Slightly simpler now.
>t

ok

> I resolved a rebase conflict in "qom: convert scalar properties to
> QAPI-aware registration".
>
> I dropped "qapi: expose integer signedness and width in introspection"
> because I don't agree with it, and couldn't be bothered to resolve the
> conflict (iirc).
>

Ok, let's discuss this separately

> I dropped "qapi: select introspectable types directly", because it's not
> needed anymore.
>



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-10-13 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09 14:04 [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 2/6] qapi: Ease access to introspection names Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 3/6] qapi/introspect: Simplify masked name comment emission slighly Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 4/6] qapi/introspect: Don't elide types Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 5/6] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop Markus Armbruster
2026-10-09 14:04 ` [RFC PATCH 6/6] qapi/introspect: Tweak integer type masking Markus Armbruster
2026-10-09 14:57 ` [RFC PATCH 0/6] qapi: Preliminary work for better QOM introspection Marc-André Lureau
2026-10-13 13:57   ` Markus Armbruster
2026-10-13 15:20     ` Marc-André Lureau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.