From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274617; cv=none; d=zoho.com; s=zohoarc; b=Hg7KBm1iGo0hCCvisg/AnCnSwQOuCZS452dt6M4c5djb/0SzsP+uSemmKFhkOb/GHI7iaHR0G+u4pMbWBloaqSw7YtR+gPWraB7/hNdWNDwrZu+y566Xdgg+WyRQ8XiV/YVnPln3pxh9ntN3Nkt9lTsBa49d1QKpt2a8KcD7PRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274617; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Oo6ZH6HF0fjI91RI0XYoZKoqx5AnaVzoYOqrgEhtq4g=; b=A5keDmM6F30FPHanOvRkflAZwtOfbg6LBXJGCHhfVr3DYq9hfnsbQMuM8z0Hqec8v8Kx8ORtiExdPBdZbXwfOv2vtJlBXOAC25fAVEvRrdxqgnCBe9GXP0mjHVotjrPcmTKTHjrmj1d2T5yaaTvFe8yFvHUqxtMn8Z23yR0viF4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274617427655.3929231680039; Wed, 20 Nov 2019 10:30:17 -0800 (PST) Received: from localhost ([::1]:33376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUk3-0000SR-Qz for importer@patchew.org; Wed, 20 Nov 2019 13:30:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37079) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfy-0003FQ-Dh for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfx-000851-55 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23364 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfx-00084o-1y for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-f-wx5KViPW6l0QYN6giuCA-1; Wed, 20 Nov 2019 13:25:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63CA9107ACC4; Wed, 20 Nov 2019 18:25:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB38963647; Wed, 20 Nov 2019 18:25:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 575F511385C7; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274360; 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=Oo6ZH6HF0fjI91RI0XYoZKoqx5AnaVzoYOqrgEhtq4g=; b=cmRNBGGGs8D2YHfx8yqDVesESM3LRD8c1WOB3v5Qf9B8kuJ7pToKsP4eSjpGJzP1QQ6gSV AUe+rgnpnDMrYSFVODK7TdnjeoYaSxBLzFw3o85YookmZjWJPmNJhnjOz3kDqzQ5lJbt8/ GONOCDzr0B9HWw7Netc7PMIpaeqVC3Q= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 1/6] qapi: Tweak "command returns a nice type" check for clarity Date: Wed, 20 Nov 2019 19:25:46 +0100 Message-Id: <20191120182551.23795-2-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: f-wx5KViPW6l0QYN6giuCA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/schema.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index cf0045f34e..cfb574c85d 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -711,10 +711,11 @@ class QAPISchemaCommand(QAPISchemaEntity): self.ret_type =3D schema.resolve_type( self._ret_type_name, self.info, "command's 'returns'") if self.name not in self.info.pragma.returns_whitelist: - if not (isinstance(self.ret_type, QAPISchemaObjectType) - or (isinstance(self.ret_type, QAPISchemaArrayType) - and isinstance(self.ret_type.element_type, - QAPISchemaObjectType))): + typ =3D self.ret_type + if isinstance(typ, QAPISchemaArrayType): + typ =3D self.ret_type.element_type + assert typ + if not isinstance(typ, QAPISchemaObjectType): raise QAPISemError( self.info, "command's 'returns' cannot take %s" --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274465; cv=none; d=zoho.com; s=zohoarc; b=MzWtF6UH9LwUJVQuLCaNbetN0xeweDOXlaEE7Uo99ZkdBEdO6rA21BTFYz16LyM9URMecE9qwZ4E81nbZ+7XXKjoWu87YnlOUV5FNMndcFtFBBWJpkg0lBFUeohq9nrdTD9gSYWOwUfrugPo+91RFswMvLx7fSHN3TaiOkv3lAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274465; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UhxbdU+S7+qS6h7wqv20wlXA0Br46p9VJroRXrgVT2g=; b=KeWsjdvWhrBqcYzNZfFjSCGobxzOi26mxnYDHRQF3OuFtU4OMuPzlISRBjVLKvc16hDjFaYE5xeM6Y4lEuVS6F0T/PQA6r2kGXE9Hr/2IhlP3YnL5wnLmgWm3ilVTbSgTi5MixgffrSUFPcjhKXNJYl7pCn9Nje8YAA2fjOYumc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274465967754.2264468001191; Wed, 20 Nov 2019 10:27:45 -0800 (PST) Received: from localhost ([::1]:33350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUhZ-0004mg-F3 for importer@patchew.org; Wed, 20 Nov 2019 13:27:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37025) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfw-0003Dy-Un for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfu-00083U-Uz for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:00 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25576 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfu-00082y-IG for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:25:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385--6IDFDFcP6WI6yt2WxwFjg-1; Wed, 20 Nov 2019 13:25:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64542801E76; Wed, 20 Nov 2019 18:25:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFDEE5ED39; Wed, 20 Nov 2019 18:25:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5A74011366CC; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274357; 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=UhxbdU+S7+qS6h7wqv20wlXA0Br46p9VJroRXrgVT2g=; b=A7HfsM4zOsYvEQeLZyWe3CEDJ1yU+/kpZViN03/kiXalEpW0IkeTx6DP1PpKutfw9z3KHy EWnLmsd884936Z7NrLnkkd6cgueuUc6t7YSOKMNCsplQMaJayX002VXbMzQ6qQY9MES8iB PQSZqqcBms0IevMHXa3Sj9/kORuUv+U= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 2/6] tests/Makefile.include: Fix missing test-qapi-emit-events.[ch] Date: Wed, 20 Nov 2019 19:25:47 +0100 Message-Id: <20191120182551.23795-3-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: -6IDFDFcP6WI6yt2WxwFjg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit 5d75648b56 "qapi: Generate QAPIEvent stuff into separate files" added tests/test-qapi-emit-events.[ch] to the set of generated files, but neglected to update tests/.gitignore and tests/Makefile.include. Commit a0af8cee3c "tests/.gitignore: ignore test-qapi-emit-events.[ch] for in-tree builds" fixed the former. Now fix the latter. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/Makefile.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 8566f5f119..75b377d1a9 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -503,6 +503,7 @@ generated-files-y +=3D tests/test-qapi-visit-sub-sub-mo= dule.h generated-files-y +=3D tests/test-qapi-commands.h generated-files-y +=3D tests/include/test-qapi-commands-sub-module.h generated-files-y +=3D tests/test-qapi-commands-sub-sub-module.h +generated-files-y +=3D tests/test-qapi-emit-events.h generated-files-y +=3D tests/test-qapi-events.h generated-files-y +=3D tests/include/test-qapi-events-sub-module.h generated-files-y +=3D tests/test-qapi-events-sub-sub-module.h @@ -610,6 +611,7 @@ tests/include/test-qapi-commands-sub-module.h \ tests/include/test-qapi-commands-sub-module.c \ tests/test-qapi-commands-sub-sub-module.h \ tests/test-qapi-commands-sub-sub-module.c \ +tests/test-qapi-emit-events.c tests/test-qapi-emit-events.h \ tests/test-qapi-events.c tests/test-qapi-events.h \ tests/include/test-qapi-events-sub-module.c \ tests/include/test-qapi-events-sub-module.h \ @@ -637,7 +639,7 @@ tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests= /qapi-schema/doc-good.jso =20 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visito= r.o $(test-qapi-obj-y) tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.= o $(test-qapi-obj-y) -tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) t= ests/test-qapi-events.o +tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) t= ests/test-qapi-emit-events.o tests/test-qapi-events.o tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visi= tor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-= obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visito= r.o $(test-qapi-obj-y) --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274584; cv=none; d=zoho.com; s=zohoarc; b=KNn56/un5sfdG5X55k/J3TRBcOug+3xYdxpF9+AMamhai2SzYWPi6YA3U8vmfKkU3Jp/iB7SlyhfnD9JUx/Qj919jJ8uhXxSMcpOoqjwqZmO74AJAcEblfoGfJ3knlXPjDU3gyPNg/noidsSr4ddrYbIJgUdpjb727v9HnkZMpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mwDhdEKbvhPI4E+lO3EFnw1XGCZjsr0NO7FQUkNKXB8=; b=e5zky9HEBPxi6e1WF73gV7lhZPK98uyvbhR3jqsmknJgdcY1W4tLNZ75388xH59tMkJOg+o7Xs7gehgr6+FvFeV0WPuoDWCq0Iq2DGdY/cEDJoBcVdClrfpCyyABtSK+4ekFlGGWkJMOfWA4gc2GAxou3XxlF6MSRjoD+0C1WaY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274584113337.4605908331623; Wed, 20 Nov 2019 10:29:44 -0800 (PST) Received: from localhost ([::1]:33372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUjV-00085O-Uv for importer@patchew.org; Wed, 20 Nov 2019 13:29:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37036) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfw-0003E4-V3 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfu-00083B-QM for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54486 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfu-00082z-GY for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:25:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-RL9yjuAiMf-E4_AQx1IwVw-1; Wed, 20 Nov 2019 13:25:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70A0D107ACC5; Wed, 20 Nov 2019 18:25:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2B9060BB8; Wed, 20 Nov 2019 18:25:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5DCDA11366CF; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274357; 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=mwDhdEKbvhPI4E+lO3EFnw1XGCZjsr0NO7FQUkNKXB8=; b=THdnKdbtHBCtf28YtejJLU8V56/dSSaw8wmB5kvuUtQTVPwuHNtBo5tY/Tsg5cgPaXrQgZ ydEkg7IXwnSQHr93LA4Mo4y8wTY3zIEeJxiRPG4wlDnafa2i+crVH2KcDadBkAFhSZTvFg 7wQek7yziX0Rt6pRcYMCAGXtOO+1Rbg= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 3/6] qapi: Generate command registration stuff into separate files Date: Wed, 20 Nov 2019 19:25:48 +0100 Message-Id: <20191120182551.23795-4-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: RL9yjuAiMf-E4_AQx1IwVw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Having to include qapi-commands.h just for qmp_init_marshal() is suboptimal. Generate it into separate files. This lets monitor/misc.c, qga/main.c, and the generated qapi-commands-FOO.h include less. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.txt | 19 ++++++++++++++++--- Makefile | 4 +++- monitor/misc.c | 7 ++++++- qga/main.c | 2 +- tests/test-qmp-cmds.c | 1 + .gitignore | 1 + qapi/Makefile.objs | 1 + qga/Makefile.objs | 1 + scripts/qapi/commands.py | 15 +++++++++++---- tests/.gitignore | 1 + tests/Makefile.include | 5 ++++- 11 files changed, 46 insertions(+), 11 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 45c93a43cc..3f37339d16 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -1493,6 +1493,10 @@ $(prefix)qapi-commands.c: Command marshal/dispatch f= unctions for each $(prefix)qapi-commands.h: Function prototypes for the QMP commands specified in the schema =20 +$(prefix)qapi-init-commands.h - Command initialization prototype + +$(prefix)qapi-init-commands.h - Command initialization code + Example: =20 $ cat qapi-generated/example-qapi-commands.h @@ -1502,11 +1506,9 @@ Example: #define EXAMPLE_QAPI_COMMANDS_H =20 #include "example-qapi-types.h" - #include "qapi/qmp/dispatch.h" =20 UserDefOne *qmp_my_command(UserDefOneList *arg1, Error **errp); void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp); - void example_qmp_init_marshal(QmpCommandList *cmds); =20 #endif /* EXAMPLE_QAPI_COMMANDS_H */ $ cat qapi-generated/example-qapi-commands.c @@ -1566,7 +1568,19 @@ Example: visit_end_struct(v, NULL); visit_free(v); } +[Uninteresting stuff omitted...] + $ cat qapi-generated/example-qapi-init-commands.h +[Uninteresting stuff omitted...] + #ifndef EXAMPLE_QAPI_INIT_COMMANDS_H + #define EXAMPLE_QAPI_INIT_COMMANDS_H =20 + #include "qapi/qmp/dispatch.h" + + void example_qmp_init_marshal(QmpCommandList *cmds); + + #endif /* EXAMPLE_QAPI_INIT_COMMANDS_H */ + $ cat qapi-generated/example-qapi-init-commands. +[Uninteresting stuff omitted...] void example_qmp_init_marshal(QmpCommandList *cmds) { QTAILQ_INIT(cmds); @@ -1574,7 +1588,6 @@ Example: qmp_register_command(cmds, "my-command", qmp_marshal_my_command, QCO_NO_OPTIONS); } - [Uninteresting stuff omitted...] =20 For a modular QAPI schema (see section Include directives), code for diff --git a/Makefile b/Makefile index b437a346d7..8dad949483 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ GENERATED_QAPI_FILES +=3D qapi/qapi-builtin-visit.h qap= i/qapi-builtin-visit.c GENERATED_QAPI_FILES +=3D qapi/qapi-visit.h qapi/qapi-visit.c GENERATED_QAPI_FILES +=3D $(QAPI_MODULES:%=3Dqapi/qapi-visit-%.h) GENERATED_QAPI_FILES +=3D $(QAPI_MODULES:%=3Dqapi/qapi-visit-%.c) +GENERATED_QAPI_FILES +=3D qapi/qapi-init-commands.h qapi/qapi-init-command= s.c GENERATED_QAPI_FILES +=3D qapi/qapi-commands.h qapi/qapi-commands.c GENERATED_QAPI_FILES +=3D $(QAPI_MODULES:%=3Dqapi/qapi-commands-%.h) GENERATED_QAPI_FILES +=3D $(QAPI_MODULES:%=3Dqapi/qapi-commands-%.c) @@ -610,6 +611,7 @@ $(SRC_PATH)/scripts/qapi-gen.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \ qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \ qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-command= s.c \ +qga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-in= it-commands.c \ qga/qapi-generated/qga-qapi-doc.texi: \ qga/qapi-generated/qapi-gen-timestamp ; qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(= qapi-py) @@ -628,7 +630,7 @@ qapi-gen-timestamp: $(qapi-modules) $(qapi-py) "GEN","$(@:%-timestamp=3D%)") @>$@ =20 -QGALIB_GEN=3D$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-vi= sit.h qga-qapi-commands.h) +QGALIB_GEN=3D$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-vi= sit.h qga-qapi-commands.h qga-qapi-init-commands.h) $(qga-obj-y): $(QGALIB_GEN) =20 qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS) diff --git a/monitor/misc.c b/monitor/misc.c index 3baa15f3bf..7c4b599342 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -66,8 +66,13 @@ #include "qemu/option.h" #include "qemu/thread.h" #include "block/qapi.h" -#include "qapi/qapi-commands.h" +#include "qapi/qapi-commands-char.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-qom.h" +#include "qapi/qapi-commands-trace.h" #include "qapi/qapi-emit-events.h" +#include "qapi/qapi-init-commands.h" #include "qapi/error.h" #include "qapi/qmp-event.h" #include "qapi/qapi-introspect.h" diff --git a/qga/main.c b/qga/main.c index c35c2a2120..e5c39c189a 100644 --- a/qga/main.c +++ b/qga/main.c @@ -24,7 +24,7 @@ #include "qapi/qmp/qjson.h" #include "qapi/qmp/qstring.h" #include "guest-agent-core.h" -#include "qga-qapi-commands.h" +#include "qga-qapi-init-commands.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "channel.h" diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 27b0afe55a..79507d9e54 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -7,6 +7,7 @@ #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" #include "test-qapi-commands.h" +#include "test-qapi-init-commands.h" =20 static QmpCommandList qmp_commands; =20 diff --git a/.gitignore b/.gitignore index 7de868d1ea..efad605e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ /qapi/qapi-emit-events.[ch] /qapi/qapi-events-*.[ch] /qapi/qapi-events.[ch] +/qapi/qapi-init-commands.[ch] /qapi/qapi-introspect.[ch] /qapi/qapi-types-*.[ch] /qapi/qapi-types.[ch] diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index dd3f5e6f94..a8f1f4c35e 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -30,3 +30,4 @@ obj-y +=3D $(QAPI_TARGET_MODULES:%=3Dqapi-events-%.o) obj-y +=3D qapi-events.o obj-y +=3D $(QAPI_TARGET_MODULES:%=3Dqapi-commands-%.o) obj-y +=3D qapi-commands.o +obj-y +=3D qapi-init-commands.o diff --git a/qga/Makefile.objs b/qga/Makefile.objs index 80e6bb3c2e..9c558ae51c 100644 --- a/qga/Makefile.objs +++ b/qga/Makefile.objs @@ -5,5 +5,6 @@ qga-obj-$(CONFIG_WIN32) +=3D commands-win32.o channel-win32= .o service-win32.o qga-obj-$(CONFIG_WIN32) +=3D vss-win32.o qga-obj-y +=3D qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-vis= it.o qga-obj-y +=3D qapi-generated/qga-qapi-commands.o +qga-obj-y +=3D qapi-generated/qga-qapi-init-commands.o =20 qga-vss-dll-obj-$(CONFIG_QGA_VSS) +=3D vss-win32/ diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index ab98e504f3..47f4a18cfe 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -263,18 +263,25 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCV= isitor): commands=3Dcommands, visit=3Dvisit)) self._genh.add(mcgen(''' #include "%(types)s.h" -#include "qapi/qmp/dispatch.h" =20 ''', types=3Dtypes)) =20 def visit_end(self): - (genc, genh) =3D self._module[self._main_module] - genh.add(mcgen(''' + self._add_system_module('init', ' * QAPI Commands initialization') + self._genh.add(mcgen(''' +#include "qapi/qmp/dispatch.h" + void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', c_prefix=3Dc_name(self._prefix, protect=3DFalse))) - genc.add(gen_registry(self._regy.get_content(), self._prefix)) + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "%(prefix)sqapi-commands.h" +#include "%(prefix)sqapi-init-commands.h" +''', + prefix=3Dself._prefix)) + self._genc.add(gen_registry(self._regy.get_content(), self._prefix= )) =20 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, diff --git a/tests/.gitignore b/tests/.gitignore index f9c0170881..7306866f21 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -12,6 +12,7 @@ test-* !test-*.c !docker/test-* test-qapi-commands.[ch] +test-qapi-init-commands.[ch] include/test-qapi-commands-sub-module.[ch] test-qapi-commands-sub-sub-module.[ch] test-qapi-emit-events.[ch] diff --git a/tests/Makefile.include b/tests/Makefile.include index 75b377d1a9..ce854ee556 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -501,6 +501,7 @@ generated-files-y +=3D tests/test-qapi-visit.h generated-files-y +=3D tests/include/test-qapi-visit-sub-module.h generated-files-y +=3D tests/test-qapi-visit-sub-sub-module.h generated-files-y +=3D tests/test-qapi-commands.h +generated-files-y +=3D tests/test-qapi-init-commands.h generated-files-y +=3D tests/include/test-qapi-commands-sub-module.h generated-files-y +=3D tests/test-qapi-commands-sub-sub-module.h generated-files-y +=3D tests/test-qapi-emit-events.h @@ -613,6 +614,8 @@ tests/test-qapi-commands-sub-sub-module.h \ tests/test-qapi-commands-sub-sub-module.c \ tests/test-qapi-emit-events.c tests/test-qapi-emit-events.h \ tests/test-qapi-events.c tests/test-qapi-events.h \ +tests/test-qapi-init-commands.c \ +tests/test-qapi-init-commands.h \ tests/include/test-qapi-events-sub-module.c \ tests/include/test-qapi-events-sub-module.h \ tests/test-qapi-events-sub-sub-module.c \ @@ -643,7 +646,7 @@ tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $= (test-qapi-obj-y) tests/t tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visi= tor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-= obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visito= r.o $(test-qapi-obj-y) -tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-comman= ds.o $(test-qapi-obj-y) +tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-comman= ds.o tests/test-qapi-init-commands.o $(test-qapi-obj-y) tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serializatio= n.o $(test-qapi-obj-y) tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-ob= j-y) =20 --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274465; cv=none; d=zoho.com; s=zohoarc; b=keTx7v/wKspugOPTQRhvlcPYt0cXy/hXAPtatjmxdaT8DUdfwb64ns683iNt4063A02Cyyt5g3mBtUhNVWWHpLLWtq4I9EwxLj4/uRod2tdRiPAD2QglK2XhQperwwzGltZio54E5JyEQn9RbHo+1MkOsKUYsrT0cfuSHROvxCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274465; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wbHKGl4VKJS7oylcaMTkmc7AQJ+X3Y4TJPOCz/mFYH4=; b=LMDXDBzd82nBs8eGFs0sZZHCQ+FGvFYf2EwlCoEdBKIVCpqB7JUtDZe/IgrVtJin72xHEsg2pCfQwn5lwyFTHbmZ5p+DumuDdSI2W3/Ba+aJSVwDpKkbaAJIfnjgXFY9fJNk5jDtsBy/y0X9AzziUjZRDfiGM+a87bTqjVRYkY8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274465053524.6601585939841; Wed, 20 Nov 2019 10:27:45 -0800 (PST) Received: from localhost ([::1]:33348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUhb-0004me-IE for importer@patchew.org; Wed, 20 Nov 2019 13:27:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37031) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfx-0003E1-15 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfu-00083M-UW for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54282 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfu-000835-QO for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:25:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-u9MBhDCINey3natO_uvxFA-1; Wed, 20 Nov 2019 13:25:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AA9D800A02; Wed, 20 Nov 2019 18:25:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7B063483A; Wed, 20 Nov 2019 18:25:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 60FD511366D1; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274358; 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=wbHKGl4VKJS7oylcaMTkmc7AQJ+X3Y4TJPOCz/mFYH4=; b=LPLWEng0tuZ33unfSi920ShQtFvNpZt0H2svXYd4UYawiwfsdn+5pN7lepLtlKiA4Z1OTd c23kpzCMASckYHL4BvJBhiVlzNkoZ6VpDzjstdx8sCfrWqhLK83TXt7Fna6N8n4wYMQo3i chbyb43aBEknpydB20wMdjJOpnu3nGo= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 4/6] qapi: Proper intermediate representation for modules Date: Wed, 20 Nov 2019 19:25:49 +0100 Message-Id: <20191120182551.23795-5-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: u9MBhDCINey3natO_uvxFA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Modules are represented only by their names so far. Introduce class QAPISchemaModule. So far, it merely wraps the name. The next patch will put it to more interesting use. Once again, arrays spice up the patch a bit. For any other type, @info points to the definition, which lets us map from @info to module. For arrays, there is no definition, and @info points to the first use instead. We have to use the element type's module instead, which is only available after .check(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/schema.py | 63 ++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index cfb574c85d..0f2e0dcfce 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -50,9 +50,6 @@ class QAPISchemaEntity(object): =20 def check(self, schema): assert not self._checked - if self.info: - self._module =3D os.path.relpath(self.info.fname, - os.path.dirname(schema.fname)) seen =3D {} for f in self.features: f.check_clash(self.info, seen) @@ -68,6 +65,13 @@ class QAPISchemaEntity(object): if self.doc: self.doc.check() =20 + def _set_module(self, schema, info): + assert self._checked + self._module =3D schema.module_by_fname(info and info.fname) + + def set_module(self, schema): + self._set_module(schema, self.info) + @property def ifcond(self): assert self._checked @@ -75,7 +79,7 @@ class QAPISchemaEntity(object): =20 @property def module(self): - assert self._checked + assert self._module or not self.info return self._module =20 def is_implicit(self): @@ -135,15 +139,19 @@ class QAPISchemaVisitor(object): pass =20 =20 +class QAPISchemaModule(object): + def __init__(self, name): + self.name =3D name + + class QAPISchemaInclude(QAPISchemaEntity): - - def __init__(self, fname, info): + def __init__(self, sub_module, info): QAPISchemaEntity.__init__(self, None, info, None) - self.fname =3D fname + self._sub_module =3D sub_module =20 def visit(self, visitor): QAPISchemaEntity.visit(self, visitor) - visitor.visit_include(self.fname, self.info) + visitor.visit_include(self._sub_module.name, self.info) =20 =20 class QAPISchemaType(QAPISchemaEntity): @@ -276,16 +284,14 @@ class QAPISchemaArrayType(QAPISchemaType): self.info and self.info.defn_meta) assert not isinstance(self.element_type, QAPISchemaArrayType) =20 + def set_module(self, schema): + self._set_module(schema, self.element_type.info) + @property def ifcond(self): assert self._checked return self.element_type.ifcond =20 - @property - def module(self): - assert self._checked - return self.element_type.module - def is_implicit(self): return True =20 @@ -783,6 +789,10 @@ class QAPISchema(object): self.docs =3D parser.docs self._entity_list =3D [] self._entity_dict =3D {} + self._module_dict =3D {} + self._schema_dir =3D os.path.dirname(fname) + self._make_module(None) # built-ins + self._make_module(fname) self._predefining =3D True self._def_predefineds() self._predefining =3D False @@ -826,14 +836,26 @@ class QAPISchema(object): info, "%s uses unknown type '%s'" % (what, name)) return typ =20 + def _module_name(self, fname): + if fname is None: + return None + return os.path.relpath(fname, self._schema_dir) + + def _make_module(self, fname): + name =3D self._module_name(fname) + if not name in self._module_dict: + self._module_dict[name] =3D QAPISchemaModule(name) + return self._module_dict[name] + + def module_by_fname(self, fname): + name =3D self._module_name(fname) + assert name in self._module_dict + return self._module_dict[name] + def _def_include(self, expr, info, doc): include =3D expr['include'] assert doc is None - main_info =3D info - while main_info.parent: - main_info =3D main_info.parent - fname =3D os.path.relpath(include, os.path.dirname(main_info.fname= )) - self._def_entity(QAPISchemaInclude(fname, info)) + self._def_entity(QAPISchemaInclude(self._make_module(include), inf= o)) =20 def _def_builtin_type(self, name, json_type, c_type): self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type)) @@ -1065,15 +1087,16 @@ class QAPISchema(object): ent.check(self) ent.connect_doc() ent.check_doc() + for ent in self._entity_list: + ent.set_module(self) =20 def visit(self, visitor): visitor.visit_begin(self) module =3D None - visitor.visit_module(module) for entity in self._entity_list: if visitor.visit_needed(entity): if entity.module !=3D module: module =3D entity.module - visitor.visit_module(module) + visitor.visit_module(module.name) entity.visit(visitor) visitor.visit_end() --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274729; cv=none; d=zoho.com; s=zohoarc; b=RZk1D0cMPrbHmT9CskixiNpYHXe0IzGdWvQ2Sy0Mm4QCOpPj4lqr/OOkQZlF3pCb9xDtaHvGrHLowLW0dveSBtnAN+HillTsHeXzP6NakpE6iIDnCOxXsgxE+fLimxDBxItDc2ztexnrmF1qeEekOBkcqOGw++oo6cM7pm1scfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274729; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hGhXnaiFPl9PqMADtLA8BuS4WbaOomCFEFwNdyl6g9k=; b=YT9C2nK8sgS2EczD3xUPAXLuZRuHSMI1tV5QDmvLXWD3o8lLKN1HVv2i/cu1U8FZbztNdhKSuvVnNwiWgabntuOS0xsBYUCnpZgpa9O81Df6kBbCJdKMhD0Z2DBXXboNsztljBUc7+f6kIPXmzwKLE9a1xg8unnp9grWEdqbyYQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274729745289.0417938168122; Wed, 20 Nov 2019 10:32:09 -0800 (PST) Received: from localhost ([::1]:33404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUls-0002Ni-Kf for importer@patchew.org; Wed, 20 Nov 2019 13:32:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37059) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfx-0003EK-R2 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfw-00084e-EE for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33960 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfw-00084D-AS for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-Y3HQNCosNwKiodo8FJCwYA-1; Wed, 20 Nov 2019 13:25:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1E69107ACCC; Wed, 20 Nov 2019 18:25:54 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C2D251962; Wed, 20 Nov 2019 18:25:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 640F511366D5; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274360; 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=hGhXnaiFPl9PqMADtLA8BuS4WbaOomCFEFwNdyl6g9k=; b=b/VwbKuVLQLIN42h+lmMgfWtMP6EE4M9ArRZ9ze76UdZ8NyG0psW4OjfjOtGa6TKpHjHMf 6DPsQZ8zPOURKZUkeM/UoysInFVUfpDMyrOshjK2U9fzxTNhxKPdMbw9PToC4qaXqqyJlV 4titPQl3j4KE8SfNFsV1ZNLsuBfRpNg= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 5/6] qapi: Fix code generation for empty modules Date: Wed, 20 Nov 2019 19:25:50 +0100 Message-Id: <20191120182551.23795-6-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: Y3HQNCosNwKiodo8FJCwYA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When a sub-module doesn't contain any definitions, we don't generate code for it, but we do generate the #include. We generate code only for modules that get visited. QAPISchema.visit() visits only modules that have definitions. It can visit modules multiple times. Clean this up as follows. Collect entities in their QAPISchemaModule. Have QAPISchema.visit() call QAPISchemaModule.visit() for each module. Have QAPISchemaModule.visit() call .visit_module() for itself, and QAPISchemaEntity.visit() for each of its entities. This way, we visit each module exactly once. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/schema.py | 24 +++++++++++++----------- tests/qapi-schema/empty.out | 1 + tests/qapi-schema/include-repetition.out | 6 ++---- tests/qapi-schema/qapi-schema-test.out | 24 ++++++++++-------------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 0f2e0dcfce..0bfc5256fb 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -68,6 +68,7 @@ class QAPISchemaEntity(object): def _set_module(self, schema, info): assert self._checked self._module =3D schema.module_by_fname(info and info.fname) + self._module.add_entity(self) =20 def set_module(self, schema): self._set_module(schema, self.info) @@ -77,11 +78,6 @@ class QAPISchemaEntity(object): assert self._checked return self._ifcond =20 - @property - def module(self): - assert self._module or not self.info - return self._module - def is_implicit(self): return not self.info =20 @@ -142,6 +138,16 @@ class QAPISchemaVisitor(object): class QAPISchemaModule(object): def __init__(self, name): self.name =3D name + self._entity_list =3D [] + + def add_entity(self, ent): + self._entity_list.append(ent) + + def visit(self, visitor): + visitor.visit_module(self.name) + for entity in self._entity_list: + if visitor.visit_needed(entity): + entity.visit(visitor) =20 =20 class QAPISchemaInclude(QAPISchemaEntity): @@ -1093,10 +1099,6 @@ class QAPISchema(object): def visit(self, visitor): visitor.visit_begin(self) module =3D None - for entity in self._entity_list: - if visitor.visit_needed(entity): - if entity.module !=3D module: - module =3D entity.module - visitor.visit_module(module.name) - entity.visit(visitor) + for mod in self._module_dict.values(): + mod.visit(visitor) visitor.visit_end() diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 5b53d00702..69666c39ad 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -9,3 +9,4 @@ enum QType member qdict member qlist member qbool +module empty.json diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 5423983239..0b654ddebb 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -11,15 +11,13 @@ enum QType member qbool module include-repetition.json include comments.json +include include-repetition-sub.json +include comments.json module comments.json enum Status member good member bad member ugly -module include-repetition.json -include include-repetition-sub.json module include-repetition-sub.json include comments.json include comments.json -module include-repetition.json -include comments.json diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3660e75a48..9bd3c4a490 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -153,9 +153,6 @@ 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 @@ -193,17 +190,6 @@ object UserDefListUnion case any: q_obj_anyList-wrapper case user: q_obj_StatusList-wrapper include include/sub-module.json -module include/sub-module.json -include sub-sub-module.json -module sub-sub-module.json -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 object q_obj_user_def_cmd1-arg @@ -435,3 +421,13 @@ command test-command-cond-features3 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] +module include/sub-module.json +include sub-sub-module.json +object SecondArrayRef + member s: StatusList optional=3DFalse +module sub-sub-module.json +array StatusList Status +enum Status + member good + member bad + member ugly --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 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; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274467; cv=none; d=zoho.com; s=zohoarc; b=BhFXfDeUm/t8LcbgG5SE1Jti/cMk+LyWyGHlem1qbji9u1mhc3yffbBlJwnbZ+NuicrGKhrlnLvZEK1Xmg5zfjUm2cXqcmg/Brc8CXQBfZR2rZtrXM3XCEdkLO7oUsyQ7SLDCpYv3EIeDccK/Pn7RbApDzaqHL95Vtd9pfbPiT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274467; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xtIiyMIliWfvUzvE7LfKSEmNI5efewvQ5sBmNuelqqo=; b=exu7iiQRkxXd6korbXsquwJBbWh0H9PFVUrVVclSkIah9Rx5pgtFNcNT9J31AxbRwaNqVVrTfENYMhHrUaYKGX4kwfXm9C9dYsqTu+n31zJv7+68nrR8NuCK7ciGB3Il+VRrEo8wlOE977w3tqGBkEUJ0FLU0Z9VO1lpIhawfSk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574274467055294.18320754254796; Wed, 20 Nov 2019 10:27:47 -0800 (PST) Received: from localhost ([::1]:33352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUhb-0004oi-Nc for importer@patchew.org; Wed, 20 Nov 2019 13:27:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37035) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXUfw-0003E3-VU for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXUfv-00083i-2z for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:26:00 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59601 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXUfu-000836-VS for qemu-devel@nongnu.org; Wed, 20 Nov 2019 13:25:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-BbbevEkSNqWPZpzPg86aQQ-1; Wed, 20 Nov 2019 13:25:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E57AFDBA9; Wed, 20 Nov 2019 18:25:54 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EABF5ED36; Wed, 20 Nov 2019 18:25:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6746F11366DB; Wed, 20 Nov 2019 19:25:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274358; 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=xtIiyMIliWfvUzvE7LfKSEmNI5efewvQ5sBmNuelqqo=; b=aOaqbsLQ7uJ0zGct0Wg07mygIzICKpLIR5Dv81WzIpczWd/0BYEKpa0F4XMJPvoN0OVXI/ g9ooNFMGXtKEUm16kqipGLyhbNga1faScTw3eYbcTpicB3ozQ/N26xif3KXz+FKaWvjsY8 NwAT3yG3sUWngDM0KSrrrejlOtfBilw= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 6/6] qapi: Simplify QAPISchemaModularCVisitor Date: Wed, 20 Nov 2019 19:25:51 +0100 Message-Id: <20191120182551.23795-7-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: BbbevEkSNqWPZpzPg86aQQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com, kwolf@pond.sub.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/commands.py | 2 +- scripts/qapi/events.py | 2 +- scripts/qapi/gen.py | 28 ++++++++++++++-------------- scripts/qapi/types.py | 5 +++-- scripts/qapi/visit.py | 8 ++++---- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 47f4a18cfe..afa55b055c 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -239,7 +239,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVis= itor): def __init__(self, prefix): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-commands', - ' * Schema-defined QAPI/QMP commands', __doc__) + ' * Schema-defined QAPI/QMP commands', None, __doc__) self._regy =3D QAPIGenCCode(None) self._visited_ret_types =3D {} =20 diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 10fc509fa9..2bde3e6128 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -140,7 +140,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisit= or): def __init__(self, prefix): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-events', - ' * Schema-defined QAPI/QMP events', __doc__) + ' * Schema-defined QAPI/QMP events', None, __doc__) self._event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DF= alse) self._event_enum_members =3D [] self._event_emit_name =3D c_name(prefix + 'qapi_event_emit') diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 112b6d94c5..95afae0615 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -201,10 +201,11 @@ class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): =20 class QAPISchemaModularCVisitor(QAPISchemaVisitor): =20 - def __init__(self, prefix, what, blurb, pydoc): + def __init__(self, prefix, what, user_blurb, builtin_blurb, pydoc): self._prefix =3D prefix self._what =3D what - self._blurb =3D blurb + self._user_blurb =3D user_blurb + self._builtin_blurb =3D builtin_blurb self._pydoc =3D pydoc self._genc =3D None self._genh =3D None @@ -245,7 +246,7 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): genc =3D QAPIGenC(basename + '.c', blurb, self._pydoc) genh =3D QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] =3D (genc, genh) - self._set_module(name) + self._genc, self._genh =3D self._module[name] =20 def _add_user_module(self, name, blurb): assert self._is_user_module(name) @@ -256,9 +257,6 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): def _add_system_module(self, name, blurb): self._add_module(name and './' + name, blurb) =20 - def _set_module(self, name): - self._genc, self._genh =3D self._module[name] - def write(self, output_dir, opt_builtins=3DFalse): for name in self._module: if self._is_builtin_module(name) and not opt_builtins: @@ -271,15 +269,17 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor): pass =20 def visit_module(self, name): - if name in self._module: - self._set_module(name) - elif self._is_builtin_module(name): - # The built-in module has not been created. No code may - # be generated. - self._genc =3D None - self._genh =3D None + if name is None: + if self._builtin_blurb: + self._add_system_module(None, self._builtin_blurb) + self._begin_system_module(name) + else: + # The built-in module has not been created. No code may + # be generated. + self._genc =3D None + self._genh =3D None else: - self._add_user_module(name, self._blurb) + self._add_user_module(name, self._user_blurb) self._begin_user_module(name) =20 def visit_include(self, name, info): diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index d8751daa04..99dcaf7074 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -243,8 +243,9 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisito= r): def __init__(self, prefix): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-types', ' * Schema-defined QAPI types', - __doc__) - self._add_system_module(None, ' * Built-in QAPI types') + ' * Built-in QAPI types', __doc__) + + def _begin_system_module(self, name): self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index c72f2bc5c0..4efce62b0c 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -285,8 +285,9 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisit= or): def __init__(self, prefix): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', - __doc__) - self._add_system_module(None, ' * Built-in QAPI visitors') + ' * Built-in QAPI visitors', __doc__) + + def _begin_system_module(self, name): self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/error.h" @@ -296,8 +297,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisit= or): #include "qapi/visitor.h" #include "qapi/qapi-builtin-types.h" =20 -''', - prefix=3Dprefix)) +''')) =20 def _begin_user_module(self, name): types =3D self._module_basename('qapi-types', name) --=20 2.21.0 From nobody Thu May 2 12:05:09 2024 Delivered-To: importer@patchew.org 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=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575024847; cv=none; d=zohomail.com; s=zohoarc; b=IZjJLavjUlj8/tIQUkodaiyihcX3DEWCXu90gqrlNKZAFnuK+cH7nzEzmCcbN6W0DSKDDI3z1TJkKHv8Gfqm0wKrAdTFvNFgsjFILEuAOvSRaMKb+lLluafOernd20YFLtmz4SBzTnP/y2OkcA5GMkylK3bJRUBe434JpyxAUbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575024847; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NuFJtOeLCF+ZRD2qYbBHzg3Tz1iz/6vPD326Ir0gOQQ=; b=PMu/9Mv4uu5SgGW+qo5YqZ0azKLohiEBYmHuez3Fi7P3rLBRxywnEF47i5RMk3LLbF/HzKULH//XTNLEIVWTY9ijw1W6Bj2Prb2n8NKAMXOxinZAVsuF0gHK2zdl8Zx8V/FbOl43EIPKKtf7OaPzx5yxtxga3ap8G7uSNBUq2CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15750248476136.006626640349168; Fri, 29 Nov 2019 02:54:07 -0800 (PST) Received: from localhost ([::1]:57046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iaduY-00061e-AR for importer@patchew.org; Fri, 29 Nov 2019 05:54:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38575) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iad3z-0001RF-JU for qemu-devel@nongnu.org; Fri, 29 Nov 2019 04:59:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iad3t-0004DN-6n for qemu-devel@nongnu.org; Fri, 29 Nov 2019 04:59:42 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49727 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iad3s-000408-0L for qemu-devel@nongnu.org; Fri, 29 Nov 2019 04:59:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-76w3fbA0OFK-8QpARZ5gFg-1; Fri, 29 Nov 2019 04:59:30 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59FF310054E3; Fri, 29 Nov 2019 09:59:29 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25F0360BE2; Fri, 29 Nov 2019 09:59:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A9A611138606; Fri, 29 Nov 2019 10:59:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575021577; 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=NuFJtOeLCF+ZRD2qYbBHzg3Tz1iz/6vPD326Ir0gOQQ=; b=hjr8wtMNLYmb3USKVnmvpossY6nPte1cEqV3kh3fQU1XqEy0V/HZmRPOp1aK42JTx1+JN5 o34U+4aDiptZ3L6hDhcODKsrv2zdyurE5aT9uzrLw/6tmpE/xWvDg87QtpxNl0QqV2yLUz TwWAAGmmhGxvzN5ExlZGIlt1/MTszlo= From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 7/6] Makefile: Make Makefile depend on generated qga files, too Date: Fri, 29 Nov 2019 10:59:27 +0100 Message-Id: <20191129095927.17382-1-armbru@redhat.com> In-Reply-To: <20191120182551.23795-1-armbru@redhat.com> References: <20191120182551.23795-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 76w3fbA0OFK-8QpARZ5gFg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Generated .h need to be generated before compiling any .c using them. To know which .h a .c uses, we need to compile it. Since commit 4115852bb0 "build: do not sprinkle around GENERATED_HEADERS dependencies", we break this circular dependency the simple & stupid way: the generated headers are a prerequisite of Makefile, which causes Make to generate them first, then start over. Except for qga we still use the older method of making all its .o summarily depend on all its generated .h (commit 016c77ad62 "Makefile: add missing deps on $(GENERATED_HEADERS)"). Add qga's generated files to generated-files-y to get rid of this exception. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 8dad949483..d4138343cd 100644 --- a/Makefile +++ b/Makefile @@ -130,6 +130,15 @@ GENERATED_QAPI_FILES +=3D qapi/qapi-doc.texi =20 generated-files-y +=3D $(GENERATED_QAPI_FILES) =20 +GENERATED_QGA_FILES :=3D qga-qapi-types.c qga-qapi-types.h +GENERATED_QGA_FILES +=3D qga-qapi-visit.c qga-qapi-visit.h +GENERATED_QGA_FILES +=3D qga-qapi-commands.h qga-qapi-commands.c +GENERATED_QGA_FILES +=3D qga-qapi-init-commands.h qga-qapi-init-commands.c +GENERATED_QGA_FILES +=3D qga-qapi-doc.texi +GENERATED_QGA_FILES :=3D $(addprefix qga/qapi-generated/, $(GENERATED_QGA_= FILES)) + +generated-files-y +=3D $(GENERATED_QGA_FILES) + generated-files-y +=3D trace/generated-tcg-tracers.h =20 generated-files-y +=3D trace/generated-helpers-wrappers.h @@ -608,12 +617,7 @@ $(SRC_PATH)/scripts/qapi/types.py \ $(SRC_PATH)/scripts/qapi/visit.py \ $(SRC_PATH)/scripts/qapi-gen.py =20 -qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \ -qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \ -qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-command= s.c \ -qga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-in= it-commands.c \ -qga/qapi-generated/qga-qapi-doc.texi: \ -qga/qapi-generated/qapi-gen-timestamp ; +$(GENERATED_QGA_FILES): qga/qapi-generated/qapi-gen-timestamp ; qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(= qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ -o qga/qapi-generated -p "qga-" $<, \ @@ -630,9 +634,6 @@ qapi-gen-timestamp: $(qapi-modules) $(qapi-py) "GEN","$(@:%-timestamp=3D%)") @>$@ =20 -QGALIB_GEN=3D$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-vi= sit.h qga-qapi-commands.h qga-qapi-init-commands.h) -$(qga-obj-y): $(QGALIB_GEN) - qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS) $(call LINK, $^) =20 @@ -722,7 +723,7 @@ clean: recurse-clean rm -f trace/generated-tracers-dtrace.h* rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp) rm -f qapi-gen-timestamp - rm -rf qga/qapi-generated + rm -f qga/qapi-generated/qapi-gen-timestamp rm -f config-all-devices.mak =20 VERSION ?=3D $(shell cat VERSION) --=20 2.21.0