From nobody Sun Nov 9 20:21:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551805847549123.13652098743626; Tue, 5 Mar 2019 09:10:47 -0800 (PST) Received: from localhost ([127.0.0.1]:46047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DaM-0000vF-Cl for importer@patchew.org; Tue, 05 Mar 2019 12:10:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DJJ-00032X-3T for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DJH-0002fg-HQ for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1DJH-0002Yh-2d for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:52:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A3E0308338F for ; Tue, 5 Mar 2019 16:52:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4E8860A9A for ; Tue, 5 Mar 2019 16:52:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BE73D113305C; Tue, 5 Mar 2019 17:52:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 17:52:36 +0100 Message-Id: <20190305165236.8389-8-armbru@redhat.com> In-Reply-To: <20190305165236.8389-1-armbru@redhat.com> References: <20190305165236.8389-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 05 Mar 2019 16:52:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] qapi: Fix array first used in a different module X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We generally put implicitly defined types in whatever module triggered their definition. This is wrong for array types, as the included test case demonstrates. Let's have a closer look at it. Type 'Status' is defined sub-sub-module.json. Array type ['Status'] occurs in main module qapi-schema-test.json and in include/sub-module.json. The main module's use is first, so the array type gets put into the main module. The generated C headers define StatusList in qapi-types.h. But include/qapi-types-sub-module.h uses it without including qapi-types.h. Oops. To fix that, put the array type into its element type's module. Now StatusList gets generated into qapi-types-sub-module.h, which all its users include. Signed-off-by: Markus Armbruster Message-Id: <20190301154051.23317-8-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/common.py | 9 +++++---- tests/qapi-schema/include/sub-module.json | 2 ++ tests/qapi-schema/qapi-schema-test.out | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index f51948364c..f07869ec73 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1089,6 +1089,9 @@ class QAPISchemaEntity(object): self.ifcond =3D typ.ifcond else: self.ifcond =3D listify_cond(self._ifcond) + if self.info: + self.module =3D os.path.relpath(self.info['file'], + os.path.dirname(schema.fname)) =20 def is_implicit(self): return not self.info @@ -1262,6 +1265,7 @@ class QAPISchemaArrayType(QAPISchemaType): self.element_type =3D schema.lookup_type(self._element_type_name) assert self.element_type self.element_type.check(schema) + self.module =3D self.element_type.module self.ifcond =3D self.element_type.ifcond =20 def is_implicit(self): @@ -1603,7 +1607,7 @@ class QAPISchemaEvent(QAPISchemaEntity): =20 class QAPISchema(object): def __init__(self, fname): - self._fname =3D fname + self.fname =3D fname if sys.version_info[0] >=3D 3: f =3D open(fname, 'r', encoding=3D'utf-8') else: @@ -1626,9 +1630,6 @@ class QAPISchema(object): self._entity_list.append(ent) if ent.name is not None: self._entity_dict[ent.name] =3D ent - if ent.info: - ent.module =3D os.path.relpath(ent.info['file'], - os.path.dirname(self._fname)) =20 def lookup_entity(self, name, typ=3DNone): ent =3D self._entity_dict.get(name) diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/= include/sub-module.json index f2bdbd3990..afdb267228 100644 --- a/tests/qapi-schema/include/sub-module.json +++ b/tests/qapi-schema/include/sub-module.json @@ -3,3 +3,5 @@ # Sub-module of ../qapi-schema-test.json =20 { 'include': '../sub-sub-module.json' } + +{ 'struct': 'SecondArrayRef', 'data': { 's': ['Status'] } } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 38c1de70d8..77fb1e1aa9 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -144,7 +144,9 @@ object q_obj_sizeList-wrapper member data: sizeList optional=3DFalse object q_obj_anyList-wrapper member data: anyList optional=3DFalse +module sub-sub-module.json array StatusList Status +module qapi-schema-test.json object q_obj_StatusList-wrapper member data: StatusList optional=3DFalse enum UserDefListUnionKind @@ -189,6 +191,9 @@ enum Status member good member bad member ugly +module include/sub-module.json +object SecondArrayRef + member s: StatusList optional=3DFalse module qapi-schema-test.json command user_def_cmd None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse --=20 2.17.2