From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554745; cv=none; d=zohomail.com; s=zohoarc; b=OiQFHxCBd+QeUiA1kSKeOIjY7cBp8M3VkF7/NBnx+yFqSyO/8OFf9sI9Wva5ZiQc++YWCLri8q4bYNWvgTfe5ZnTYPiNyogwgxLPfKunV30yTBPyl9vsklnZ5oeKmuHXpNM/0ZsvRdBHCLBjaCnw8mtHT4DZVUWMqcfCp65pHEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554745; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9s+13MqC59E8bYJ9f4X5Mw2tM98XxqkQLGi0V+Eo/do=; b=hF/nInrCrGxE4HZQaVyWEMbV9Bpmm1LYrMXI0FzvMH127ULeRleSdJ1InhCwclGxHbsfQ5vnUyPUzm6LBBTAw2jAix7Jf9iVz4tYHKWuhTdjCG7vruVxpRdrvYYLN6YaWNa0NJzL31qwW3LKDhYiYfEz85xQDcEox6N4uNWIwgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791554745383370.39971243134016; Fri, 9 Oct 2026 07:05:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDJ-0000sn-C7; Fri, 09 Oct 2026 10:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDG-0000s1-R0 for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDD-0007TB-CM for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-DiswULCnPvm7uFFZ_7GxvA-1; Fri, 9 Oct 2026 14:04:35 +0000 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2858318345A1; Fri, 9 Oct 2026 14:04:34 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B224541D; Fri, 9 Oct 2026 14:04:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 49D3F21E692D; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9s+13MqC59E8bYJ9f4X5Mw2tM98XxqkQLGi0V+Eo/do=; b=Bztt97R90fPm41OfP3aPQEf9GenrJIUXvvBQ4SYOmmXPLyc8OZJKRsMhm9x2ny+f/5Uuu6 E+wHcYiWy0/66PfJug2YnwgydWS0j5D4b6v3HVkDZ0nlqz3z438BFwPArP3/morvfX1CDV IGQ5mVziZ99YrBkw5rn610HVJfyG4uI= X-MC-Unique: DiswULCnPvm7uFFZ_7GxvA-1 X-Mimecast-MFC-AGG-ID: DiswULCnPvm7uFFZ_7GxvA_1791554674 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 1/6] qapi/schema: Rename .lookup_entity() and tighten return type Date: Fri, 9 Oct 2026 16:04:26 +0200 Message-ID: <20261009140431.3175479-2-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554747334158500 Content-Type: text/plain; charset="utf-8" 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 --- 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.Ele= ment: modules.add(module_source) =20 if doc.symbol: - ent =3D schema.lookup_entity(doc.symbol) + ent =3D 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: QAPISchemaDefinitio= n) -> None: defn.info, "%s is already defined" % other_defn.describe()) self._entity_dict[defn.name] =3D defn =20 - def lookup_entity(self, name: str) -> Optional[QAPISchemaEntity]: + def lookup_defn(self, name: str) -> Optional[QAPISchemaDefinition]: return self._entity_dict.get(name) =20 def lookup_type(self, name: str) -> Optional[QAPISchemaType]: - typ =3D self.lookup_entity(name) + typ =3D 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 =3D 'q_obj_%s-%s' % (name, role) - typ =3D self.lookup_entity(name) + typ =3D self.lookup_defn(name) if typ: assert isinstance(typ, QAPISchemaObjectType) # The implicit object type has multiple users. This can --=20 2.55.0 From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554713; cv=none; d=zohomail.com; s=zohoarc; b=Hs/6kwgh0G4fA6kRzm/GnzZXlg9EMNV56x5aySgo8+pqMpR7ssaBCQ9UWgqR2Is8AYivPj9daC1DNMFcFoZw1swDg0e8ixssuoG8oBHKyBP+295usbCaJiu/RIs92yF7uk12B7UfDgUZ5QZeXEgcvs83RMtrxVhEafAlPJXHa2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554713; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QBbuTqoPq1NM6KRF8rX74ImioIWIDBiC2afETo0yPJI=; b=nqCXpKY/2D8ZBheuHyMPxI0pATTXOorIuUzuZ845DpVqWbsQlmmoLDdTpni2A5P8Ob2WCaf/aTC6U8me04n1CqmarIOTUUMbgQctRrNYvVyA9fGdyxYIqmAd6WGf6FlORkifc5Nf0Z8Hq+WveQvFj1xOzRlZm4l2GvoOFeOv32E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791554713640745.4609277391869; Fri, 9 Oct 2026 07:05:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDI-0000sS-HE; Fri, 09 Oct 2026 10:04:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDG-0000rs-1g for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDD-0007T2-Bj for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:41 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-mpO6M0i5PlaRlXv5xH0fYg-1; Fri, 9 Oct 2026 14:04:35 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 66A6C19560A2; Fri, 9 Oct 2026 14:04:34 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C5A1218005B5; Fri, 9 Oct 2026 14:04:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4DFA821E6880; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QBbuTqoPq1NM6KRF8rX74ImioIWIDBiC2afETo0yPJI=; b=DTACXFzQ3keI/W5yF1ld9+420M2QGqtKzo0VzErOAYwcwFV7cJUgnD1QD5PFWMfVSuy7m+ VT2GmLfIiZff0OT6AXv9PYrrOmKNVYLgpE4ISa3vi+hfjqLkLWQ+hDTZAm4Ff1De5Ishkp X1sj4+dJU9IdEV0Y2AEFYQ8Zl1d/Q/g= X-MC-Unique: mpO6M0i5PlaRlXv5xH0fYg-1 X-Mimecast-MFC-AGG-ID: mpO6M0i5PlaRlXv5xH0fYg_1791554674 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 2/6] qapi: Ease access to introspection names Date: Fri, 9 Oct 2026 16:04:27 +0200 Message-ID: <20261009140431.3175479-3-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554714991158500 query-qmp-schema masks type names, because they are not part of the external interface. Marc-Andr=C3=A9 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 --- 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] =3D None self._trees: List[Annotated[SchemaInfo]] =3D [] self._used_types: List[QAPISchemaType] =3D [] - self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqapi-introspect.h" @@ -208,18 +206,14 @@ def visit_end(self) -> None: self._schema =3D None self._trees =3D [] self._used_types =3D [] - self._name_map =3D {} =20 def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Ignore types on first pass; visit_end() will pick up used types return not isinstance(entity, QAPISchemaType) =20 def _name(self, name: str) -> str: - if self._unmask: - return name - if name not in self._name_map: - self._name_map[name] =3D '%d' % len(self._name_map) - return self._name_map[name] + assert self._schema + return self._schema.definition_introspection_name(name, self._unma= sk) =20 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) =20 @staticmethod @@ -271,8 +258,7 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[st= r, object], # Output a comment to make it easy to map masked names # back to the source when reading the generated output. comment =3D f'"{self._name(name)}" =3D {name}' - name =3D self._name(name) - obj['name'] =3D name + obj['name'] =3D self._name(name) obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) @@ -327,8 +313,7 @@ def visit_array_type(self, name: str, info: Optional[QA= PISourceInfo], ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: element =3D self._use_type(element_type) - self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, - ifcond) + self._gen_tree(name, 'array', {'element-type': element}, ifcond) =20 def visit_object_type_flat(self, name: str, info: Optional[QAPISourceI= nfo], 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) =20 + def set_ordinal(self, ordinal: int) -> None: + pass + + # pylint: disable=3Dunused-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: =20 =20 class QAPISchemaType(QAPISchemaDefinition, ABC): + def __init__( + self, + name: str, + info: Optional[QAPISourceInfo], + doc: Optional[QAPIDoc], + ifcond: Optional[QAPISchemaIfCond] =3D None, + features: Optional[List[QAPISchemaFeature]] =3D None, + ): + super().__init__(name, info, doc, ifcond, features) + self._masked_name: Optional[str] =3D 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) =20 + def set_ordinal(self, ordinal: int) -> None: + assert not self._masked_name + self._masked_name =3D 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() =20 + def introspection_name(self, unmask: bool): + if self.json_type() =3D=3D '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 =20 + 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] =3D defn =20 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 =20 + def definition_introspection_name(self, name: str, unmask: bool) -> st= r: + defn =3D 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 --=20 2.55.0 From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554713; cv=none; d=zohomail.com; s=zohoarc; b=K+aSM42u667ECf4jdbRmUFH2koJlUbqXPPh1JJXqwu3gZh4vRBB6VnRiQn6JvKlb4u2T2580f85gi1aIyRuKTk2i/S3oehHzfC6RO1WMqIxlCuT/Ad2lBsxIkHt2pSu6nALhetqLqLm37/AsxMz0KO9HpFoGPJ0w3+CKwDQZ+uE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554713; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vZwieRBJR5bGNH1g9WPO9iUQzQBm2BUud1lnpQQFdg4=; b=gjiAonffgFtnS/efMkhi/TwakFM1Z+ALy/+dMAtl5GG5Ehypu0Akx/65Tc2LN0HnPRspwiXMyahl79H22uz3qNbwarpWLXu5V3P/4gfdT1A/cwmESDXCmJNDqxccq4AxFY8m+6jce04dpLVYHXVsRIvaAPLn5u0NT5BwOB3fNQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17915547130031013.4567853503368; Fri, 9 Oct 2026 07:05:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDJ-0000t0-Qm; Fri, 09 Oct 2026 10:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDG-0000s2-ST for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDE-0007TF-Gq for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-b-Zzi0OsOA-YRMCWD84cLA-1; Fri, 9 Oct 2026 14:04:35 +0000 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 369691955F17; Fri, 9 Oct 2026 14:04:34 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6F241800591; Fri, 9 Oct 2026 14:04:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 521A721E6882; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZwieRBJR5bGNH1g9WPO9iUQzQBm2BUud1lnpQQFdg4=; b=RaBqXXlxw/YHO3rclswkd3a8fGE57ZPQ+xxNXU3wa9C8avdVAZhYSUNekmvNWednsK+5Ap UfQlw1xCAT/3QkCM0ZM/yQV+ewdpgssrASvWUdUO7SYs3TgbwLfGbHUksKUraSXpT/gBgm fMVq7OznH2lb6kgimgn2U6lAn8PYOvs= X-MC-Unique: b-Zzi0OsOA-YRMCWD84cLA-1 X-Mimecast-MFC-AGG-ID: b-Zzi0OsOA-YRMCWD84cLA_1791554674 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 3/6] qapi/introspect: Simplify masked name comment emission slighly Date: Fri, 9 Oct 2026 16:04:28 +0200 Message-ID: <20261009140431.3175479-4-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554714908158500 Content-Type: text/plain; charset="utf-8" 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 --- 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] =3D 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 =3D f'"{self._name(name)}" =3D {name}' - obj['name'] =3D self._name(name) + introspection_name =3D self._name(name) + if introspection_name !=3D name: + # Output a comment to make it easy to map masked names + # back to the source when reading the generated output. + comment =3D f'"{introspection_name}" =3D {name}' + obj['name'] =3D introspection_name obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) --=20 2.55.0 From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554712; cv=none; d=zohomail.com; s=zohoarc; b=aQ6wrcc18yPG82cUZdzFRUNLoo24kGgmt+vLSUi0qYBZ7NnymZRkFJfXl8uD2UIsOpC9iXMr3er1bzT5G9X3KR4vKUjf5yJLQuqbUP8eGwjuWcNiHqBizbAeO/urafJKjC9DyvvvZbr+Hv2KbWzwaa1qoqkp8OkToP9Zm5UW4iQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554712; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r7j/xoTFi8J56u7Lizjo2qLZPXawPskxyd5srOi+aZY=; b=S197ylPGumzNNZ87nbt4sT93VJd6cu5IYzHs20wYaGh3SRrcoRkMZGWvmsn7n1xVRSFLKiCfLNDcD9TFTlaVY1YhVFgE6RkiS3U88wVjX2usSVZ14MlaguMHgOsK6cSoyrrK3iWk4GAFL8acJJXigwCWItN/MUR727NL5WN477g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791554712559509.95227587099134; Fri, 9 Oct 2026 07:05:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDI-0000sM-5V; Fri, 09 Oct 2026 10:04:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDF-0000rk-Ln for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDD-0007T1-CG for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:41 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-GtE3I6CVM5queF__KBVoMQ-1; Fri, 9 Oct 2026 14:04:35 +0000 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 33CFD1955F71; Fri, 9 Oct 2026 14:04:34 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 972B730001BB; Fri, 9 Oct 2026 14:04:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5619821E6883; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r7j/xoTFi8J56u7Lizjo2qLZPXawPskxyd5srOi+aZY=; b=W7+kdRlIXQSI11K5Z7ihvi9kvuZW7a8jdysmmevFmF44rgHb2tL4koXc1qNaYN4vBI/3sB 1AF/YlVa40/5tzeELsHW55i7QOmGV0brDblMbzCRsmgc1+yZkB6enL5PBVFsclwtu2aNMo LqKCuuTcmydpdubETPJMCzANV0n/uiU= X-MC-Unique: GtE3I6CVM5queF__KBVoMQ-1 X-Mimecast-MFC-AGG-ID: GtE3I6CVM5queF__KBVoMQ_1791554674 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 4/6] qapi/introspect: Don't elide types Date: Fri, 9 Oct 2026 16:04:29 +0200 Message-ID: <20261009140431.3175479-5-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554714942158500 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=C3=A9 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 --- 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 =3D unmask self._schema: Optional[QAPISchema] =3D None self._trees: List[Annotated[SchemaInfo]] =3D [] - self._used_types: List[QAPISchemaType] =3D [] 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 =3D schema =20 def visit_end(self) -> None: - # visit the types that are actually used - for typ in self._used_types: - typ.visit(self) - # generate C name =3D c_name(self._prefix, protect=3DFalse) + 'qmp_schema_qlit' self._genh.add(mcgen(''' #include "qobject/qlit.h" @@ -205,32 +198,12 @@ def visit_end(self) -> None: c_string=3D_tree_to_qlit(self._trees))) self._schema =3D None self._trees =3D [] - self._used_types =3D [] - - def visit_needed(self, entity: QAPISchemaEntity) -> bool: - # Ignore types on first pass; visit_end() will pick up used types - return not isinstance(entity, QAPISchemaType) =20 def _name(self, name: str) -> str: assert self._schema return self._schema.definition_introspection_name(name, self._unma= sk) =20 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() =3D=3D 'int': - type_int =3D self._schema.lookup_type('int') - assert type_int - typ =3D type_int - elif (isinstance(typ, QAPISchemaArrayType) and - typ.element_type.json_type() =3D=3D 'int'): - type_intlist =3D self._schema.lookup_type('intList') - assert type_intlist - typ =3D 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) =20 @staticmethod @@ -295,6 +268,8 @@ def _gen_variant(self, variant: QAPISchemaVariant =20 def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], json_type: str) -> None: + if json_type =3D=3D 'int' and name !=3D 'int': + return self._gen_tree(name, 'builtin', {'json-type': json_type}) =20 def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], @@ -312,6 +287,8 @@ def visit_enum_type(self, name: str, info: Optional[QAP= ISourceInfo], def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: + if element_type.json_type() =3D=3D 'int' and name !=3D 'intList': + return element =3D self._use_type(element_type) self._gen_tree(name, 'array', {'element-type': element}, ifcond) =20 --=20 2.55.0 From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554748; cv=none; d=zohomail.com; s=zohoarc; b=ioS363aHAepdyIcVMPpECSeEaXPVvHedu6xO8UqbtCJ434bxdlsg9XHXjAQVLOz4uely5WlWfaF6GHxgP1NXwy7g+uBfSBQSYZJQvibB+mRSDBs6JcAzliBy+oxg32O/GvME8idN0r6YIpYD3R58j2xa7BavDHnW0dfjByhtqaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554748; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B2alIP8jKln//VCQ4oUpDoAEG8zxQvPiKhuCbdtOD1A=; b=fiatN0GHRg5jlIQqaNWVbSo85Lx3siZcKZcQDH/M5CkkrKSl2xI9tmKKUPh5VBsPaiZcsT2vMpNXLxfcgPnCYfmn2JjXkkriG24z6cOlXQ440ChFf8OCANgOs54XgB70AXMSW0I6qvlheuLoftSDrdsdJCdwzlQgKxjfDpmvGfY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791554748631245.97243930026957; Fri, 9 Oct 2026 07:05:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDJ-0000so-Du; Fri, 09 Oct 2026 10:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDG-0000s3-TZ for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDF-0007TL-7j for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:42 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-y-KED8bSNKGiW3tetIjEIQ-1; Fri, 9 Oct 2026 14:04:38 +0000 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E578C18345A8; Fri, 9 Oct 2026 14:04:36 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9A46D1956095; Fri, 9 Oct 2026 14:04:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5A2B621E6884; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B2alIP8jKln//VCQ4oUpDoAEG8zxQvPiKhuCbdtOD1A=; b=HUJWlP4D9raJqzONz4QXiQym+fo9YIRT+VVVWmq6G1YPpu2EIBb7+pqlFaYAsQXFQP8J15 aaVPiWB2JqTNZhd/3kBCtbsZgj4mukyrRX+Fc0K61b3AAZWzQKI97Xt82N29WlsL5ofo0I vP1NsSNwRZ2uk8NhqFF5dsvcya5z7SU= X-MC-Unique: y-KED8bSNKGiW3tetIjEIQ-1 X-Mimecast-MFC-AGG-ID: y-KED8bSNKGiW3tetIjEIQ_1791554677 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 5/6] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop Date: Fri, 9 Oct 2026 16:04:30 +0200 Message-ID: <20261009140431.3175479-6-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554751565158501 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- 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 =20 - def visit_needed(self, entity: QAPISchemaEntity) -> bool: - # pylint: disable=3Dunused-argument - # Default to visiting everything - return True - def visit_include(self, name: str, info: Optional[QAPISourceInfo]) -> = None: pass =20 @@ -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) =20 =20 class QAPISchemaInclude(QAPISchemaEntity): --=20 2.55.0 From nobody Thu Oct 22 19:25:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791554721; cv=none; d=zohomail.com; s=zohoarc; b=VMAePtq0fljsYdQQBc6KsngMQm7xp75bp2Ghu4cxOFTjhU2RdMc6/n77n8aN56mx+6e8JUGtOZKrCzRECBWvFsq8YT+v/PFCMsXjQX8DPhFjvZUpWamlOnFjgUSnFvWQ/dXaN+dU1SvCEXfmXTfOgOa4PwHxfOtG2RSyLYhZbJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791554721; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zmlXgzNE4BsM+gSTwsbMzIiXDHGXqNkooV3t9InUBt8=; b=FyFD1MbEj7nrcneRnnZNs+c144UdKfgMXgGQ7+GtfbsI540l6Atpuzfxa01suX6kR0HnwWzw8bVnoAdYRz508P2LzrWOFMEVBX6juI35HySKdFalR+XqPDFFDBS7vdPhIU4+bCcaF84jWZI2U5/4egNqqOqM/ipfCXpJyAgJNd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791554721202555.8473519165229; Fri, 9 Oct 2026 07:05:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xFBDJ-0000tG-Vy; Fri, 09 Oct 2026 10:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDI-0000sT-EJ for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xFBDG-0007Tk-Vv for qemu-devel@nongnu.org; Fri, 09 Oct 2026 10:04:44 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-_GK4jmoAO_iACpSC0K-Uzg-1; Fri, 9 Oct 2026 14:04:39 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 053181955D93; Fri, 9 Oct 2026 14:04:37 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B287E1800361; Fri, 9 Oct 2026 14:04:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5E77A21E6885; Fri, 09 Oct 2026 16:04:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791554682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zmlXgzNE4BsM+gSTwsbMzIiXDHGXqNkooV3t9InUBt8=; b=KZNz7dfYTv0u2y5fEnmYUK08CWvyKly8UVHHl4hVscT8xEOGdqTaO2lS5WAkxESw6mEgXn hJuYUtGkPyDU5d4aaX9nT2GeiI360dlCworXbho5OX6mYop3I4oPGVh+/ZITt3ljvzdCpS 0WHQWrhLMWWQaNO4xX5gCV5nSfJzo9U= X-MC-Unique: _GK4jmoAO_iACpSC0K-Uzg-1 X-Mimecast-MFC-AGG-ID: _GK4jmoAO_iACpSC0K-Uzg_1791554677 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, michael.roth@amd.com, jsnow@redhat.com Subject: [RFC PATCH 6/6] qapi/introspect: Tweak integer type masking Date: Fri, 9 Oct 2026 16:04:31 +0200 Message-ID: <20261009140431.3175479-7-armbru@redhat.com> In-Reply-To: <20261009140431.3175479-1-armbru@redhat.com> References: <20261009140431.3175479-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791554722990158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D unmask self._schema: Optional[QAPISchema] =3D None - self._trees: List[Annotated[SchemaInfo]] =3D [] + self._trees: Dict[str, Annotated[SchemaInfo]] =3D {} 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=3Dc_name(name))) + trees =3D list(self._trees.values()) self._genc.add(mcgen(''' const QLitObject %(c_name)s =3D %(c_string)s; ''', c_name=3Dc_name(name), - c_string=3D_tree_to_qlit(self._trees))) + c_string=3D_tree_to_qlit(trees))) self._schema =3D None - self._trees =3D [] + self._trees =3D {} =20 def _name(self, name: str) -> str: assert self._schema @@ -235,7 +236,12 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[s= tr, object], obj['meta-type'] =3D mtype if features: obj['features'] =3D 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] =3D Annotated(obj, ifcond, comment) =20 def _gen_enum_member(self, member: QAPISchemaEnumMember ) -> Annotated[SchemaInfoEnumMember]: @@ -268,8 +274,6 @@ def _gen_variant(self, variant: QAPISchemaVariant =20 def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], json_type: str) -> None: - if json_type =3D=3D 'int' and name !=3D 'int': - return self._gen_tree(name, 'builtin', {'json-type': json_type}) =20 def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], @@ -287,8 +291,6 @@ def visit_enum_type(self, name: str, info: Optional[QAP= ISourceInfo], def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: - if element_type.json_type() =3D=3D 'int' and name !=3D 'intList': - return element =3D self._use_type(element_type) self._gen_tree(name, 'array', {'element-type': element}, ifcond) =20 --=20 2.55.0