From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981360; cv=none; d=zohomail.com; s=zohoarc; b=DdGIBsIhiO0RBhdx1Fynqxi58ywfhFSF/fwSJBnR8e8PE9ggmnQCxy5reJR3foU2TubpMg49W+D3rE9eyGBOFKjMloJ5PtD3gDf3vgsUHJS9xBpBxD7shPX49GOMToijFW4vHHaO9fGH7dbpq8h/TKcbEIvyFNss30yGe5/yr20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981360; 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=tad11opssmnVeXRaOe4HhaYIssHpPLxaNvEbtnekugw=; b=JpoTlBAFHyuZGBvW2cMjJZod1R2u1SYKBh3Kw17MM7tqF+c3NyDA+7X5Mwt3j/5flokklCDZnSmPYeLJgl1Vbr8TsiSyebiKIu3jl9zQbdLicCZWLtNz5/uTAXRlp3RSw+8EFnZ442toMBYLjlCRloXymmec2IYpAJh2jNTa85k= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981360021308.00982156157374; Thu, 26 Aug 2021 05:36:00 -0700 (PDT) Received: from localhost ([::1]:52034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEbt-0006tX-PT for importer@patchew.org; Thu, 26 Aug 2021 08:35:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYb-0004A5-Ir for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYZ-00088D-49 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:32 -0400 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-260-AEnHi9W2Ny2RjoMoWqvuPg-1; Thu, 26 Aug 2021 08:32:28 -0400 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 48D61108292D; Thu, 26 Aug 2021 12:32:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B6B85D9C6; Thu, 26 Aug 2021 12:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9477A11380AA; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981149; 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=tad11opssmnVeXRaOe4HhaYIssHpPLxaNvEbtnekugw=; b=foKd8hi2ZcHcFs193VnoWhS1eKFA2bK5Vu548LAz9MCWYxgLlFDeUCUL4qFM4hy5e8cZgU gJfYwq1rje1KlXBbeQW3uXAEbFk7wLNrOiBIT4/RE6Guar0mXY260LyVmr58JN1+bKUP5F IZsM4QaoDikLrx3+PvG/Mic9nOo0OyU= X-MC-Unique: AEnHi9W2Ny2RjoMoWqvuPg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/11] qapi: Fix crash on redefinition with a different condition Date: Thu, 26 Aug 2021 14:32:15 +0200 Message-Id: <20210826123225.157891-2-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981360863100003 Content-Type: text/plain; charset="utf-8" QAPISchema._make_implicit_object_type() asserts that when an implicit object type is used multiple times, @ifcond is the same for all uses. It will be for legitimate uses, i.e. simple union branch wrapper types. A comment explains this. The assertion fails when a command or event is redefined with a different condition. The redefinition is an error, but it's flagged only later. Fixing the assertion would complicate matters further. Not worthwhile, drop it instead. We really need to get rid of simple unions. Tweak test case redefined-event to cover redefinition with a different condition. Signed-off-by: Markus Armbruster Message-Id: <20210806120510.2367124-1-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/schema.py | 22 +++++++++++----------- tests/qapi-schema/redefined-event.json | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index d1d27ff7ee..a4ce3972a4 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -997,18 +997,18 @@ def _make_implicit_object_type(self, name, info, ifco= nd, role, members): name =3D 'q_obj_%s-%s' % (name, role) typ =3D self.lookup_entity(name, QAPISchemaObjectType) if typ: - # The implicit object type has multiple users. This can - # happen only for simple unions' implicit wrapper types. - # Its ifcond should be the disjunction of its user's - # ifconds. Not implemented. Instead, we always pass the - # wrapped type's ifcond, which is trivially the same for all - # users. It's also necessary for the wrapper to compile. - # But it's not tight: the disjunction need not imply it. We - # may end up compiling useless wrapper types. + # The implicit object type has multiple users. This is + # either a duplicate definition (which will be flagged + # later), or an implicit wrapper type used for multiple + # simple unions. In the latter case, ifcond should be the + # disjunction of its user's ifconds. Not implemented. + # Instead, we always pass the wrapped type's ifcond, which + # is trivially the same for all users. It's also + # necessary for the wrapper to compile. But it's not + # tight: the disjunction need not imply it. We may end up + # compiling useless wrapper types. # TODO kill simple unions or implement the disjunction - - # pylint: disable=3Dprotected-access - assert (ifcond or []) =3D=3D typ._ifcond + pass else: self._def_entity(QAPISchemaObjectType( name, info, None, ifcond, None, None, members, None)) diff --git a/tests/qapi-schema/redefined-event.json b/tests/qapi-schema/red= efined-event.json index 7717e91c18..09eff18412 100644 --- a/tests/qapi-schema/redefined-event.json +++ b/tests/qapi-schema/redefined-event.json @@ -1,3 +1,3 @@ # we reject duplicate events { 'event': 'EVENT_A', 'data': { 'myint': 'int' } } -{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } } +{ 'event': 'EVENT_A', 'data': { 'myint': 'int' }, 'if': 'defined(FOO)' } --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 Delivered-To: importer@patchew.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981360114110.33259164259528; Thu, 26 Aug 2021 05:36:00 -0700 (PDT) Received: from localhost ([::1]:52172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEbu-000705-VW for importer@patchew.org; Thu, 26 Aug 2021 08:35:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYn-0004Ak-7s for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYi-0008C1-6k for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:45 -0400 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-3-kKe2Hxn-NhqQMfO-VXJlWQ-1; Thu, 26 Aug 2021 08:32:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A578E87D541; Thu, 26 Aug 2021 12:32:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B6D95C1D5; Thu, 26 Aug 2021 12:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9C32111380AB; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981157; 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=PsTutcg/lRrtWDE4iFDlyr/ZBBbqmo2DXv8ZTmGwZcM=; b=Qk8kX5g5XQYoYdwETb31QriebPumfohDtEtLINAWrKSLpth+joUPKHvlXyfYOrPLGuvwNY X2rPYBFbygNlHLS1vvp66fqTA/J1KavXHQ+GlagVU/rm23BHdUhrClD1UJy+CdCF6pRd3i KnbJjTBQHdivZFst4z+RclmcUqrcvfc= X-MC-Unique: kKe2Hxn-NhqQMfO-VXJlWQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 02/11] docs: update the documentation upfront about schema configuration Date: Thu, 26 Aug 2021 14:32:16 +0200 Message-Id: <20210826123225.157891-3-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629981360845100002 From: Marc-Andr=C3=A9 Lureau Update the documentation describing the changes in this series. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi Tested-by: John Snow Reviewed-by: Markus Armbruster Message-Id: <20210804083105.97531-2-marcandre.lureau@redhat.com> [Rebased with straightforward conflicts] Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.rst | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 26c62b0e7b..ced7a5ffe1 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -826,25 +826,31 @@ Configuring the schema Syntax:: =20 COND =3D STRING - | [ STRING, ... ] + | { 'all: [ COND, ... ] } + | { 'any: [ COND, ... ] } + | { 'not': COND } =20 All definitions take an optional 'if' member. Its value must be a -string or a list of strings. A string is shorthand for a list -containing just that string. The code generated for the definition -will then be guarded by #if STRING for each STRING in the COND list. +string, or an object with a single member 'all', 'any' or 'not'. + +The C code generated for the definition will then be guarded by an #if +preprocessing directive with an operand generated from that condition: + + * STRING will generate defined(STRING) + * { 'all': [COND, ...] } will generate (COND && ...) + * { 'any': [COND, ...] } will generate (COND || ...) + * { 'not': COND } will generate !COND =20 Example: a conditional struct :: =20 { 'struct': 'IfStruct', 'data': { 'foo': 'int' }, - 'if': ['defined(CONFIG_FOO)', 'defined(HAVE_BAR)'] } + 'if': { 'all': [ 'CONFIG_FOO', 'HAVE_BAR' ] } } =20 gets its generated code guarded like this:: =20 - #if defined(CONFIG_FOO) - #if defined(HAVE_BAR) + #if defined(CONFIG_FOO) && defined(HAVE_BAR) ... generated code ... - #endif /* defined(HAVE_BAR) */ - #endif /* defined(CONFIG_FOO) */ + #endif /* defined(HAVE_BAR) && defined(CONFIG_FOO) */ =20 Individual members of complex types, commands arguments, and event-specific data can also be made conditional. This requires the @@ -855,7 +861,7 @@ member 'bar' :: =20 { 'struct': 'IfStruct', 'data': { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'defined(IFCOND)'} } } + 'bar': { 'type': 'int', 'if': 'IFCOND'} } } =20 A union's discriminator may not be conditional. =20 @@ -867,7 +873,7 @@ value 'bar' :: =20 { 'enum': 'IfEnum', 'data': [ 'foo', - { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] } + { 'name' : 'bar', 'if': 'IFCOND' } ] } =20 Likewise, features can be conditional. This requires the longhand form of FEATURE_. @@ -877,7 +883,7 @@ Example: a struct with conditional feature 'allow-negat= ive-numbers' :: { 'struct': 'TestType', 'data': { 'number': 'int' }, 'features': [ { 'name': 'allow-negative-numbers', - 'if': 'defined(IFCOND)' } ] } + 'if': 'IFCOND' } ] } =20 Please note that you are responsible to ensure that the C code will compile with an arbitrary combination of conditions, since the --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981943; cv=none; d=zohomail.com; s=zohoarc; b=W/3uJU8pDpPGqp5aJZk4ji2zKmAQNwBAkd31DqejiMSirXgrzBIAIOSV9OaPtgEjx3T3R6gkZ0jy/2V/7gdoYxetbGnNBfI7vNDpQr8eNTt/LDa+y7DNIHQqYRJobedIZPy+46nS+QggXBoivgFn2Q5LYzOqj5M4YWa2+4A9XDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981943; 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=Ha0NRGszXRvuXu1cqMClRbRl26czxc5YfaiZYrO3UXM=; b=jwXmlWNUAV3pvGektb/0ez0KLbcy/gsa10fBmRAr5s9s+pdFGTbMjse0iFg7Zc77hn/aHs3Xv/dLvH9ArKKKxCIrN9KJ5tbWTwc3bhX/Eo/eYyo7BJfY0AOwa/TX7SCj665yDOQjwKsJBqRMG1Yatpa7GpALswatdpn51B+FJXw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981943727777.1250696976518; Thu, 26 Aug 2021 05:45:43 -0700 (PDT) Received: from localhost ([::1]:42486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJElK-0002jG-MP for importer@patchew.org; Thu, 26 Aug 2021 08:45:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYw-0004D6-Oa for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYj-0008D0-An for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:54 -0400 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-420-VEGGKAqUNOeDw6WjaKs5iw-1; Thu, 26 Aug 2021 08:32:33 -0400 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 54AD11966321; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B87027CA8; Thu, 26 Aug 2021 12:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A00E611380B0; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981160; 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=Ha0NRGszXRvuXu1cqMClRbRl26czxc5YfaiZYrO3UXM=; b=AitU7up1DcuBU13a/IzQV3ENCP1HF6R5kSwwC5CNF79WjCCFUw3A4eiCc2KizuLDLmXlVg /+BuqOpQVqlAwKqOMy9BIl1a8zXHXwXIAVy0a5ID3oFIWlcpmSEMo8wAQwgjC//F2oOBhE fdcZcCNsRLdJksXkPizZrSNXXhwZFek= X-MC-Unique: VEGGKAqUNOeDw6WjaKs5iw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 03/11] qapi: wrap Sequence[str] in an object Date: Thu, 26 Aug 2021 14:32:17 +0200 Message-Id: <20210826123225.157891-4-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981944951100001 From: Marc-Andr=C3=A9 Lureau Mechanical change, except for a new assertion in QAPISchemaEntity.ifcond(). Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-3-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Rebased with obvious conflicts, commit message adjusted] Signed-off-by: Markus Armbruster --- docs/sphinx/qapidoc.py | 10 +++--- scripts/qapi/commands.py | 4 +-- scripts/qapi/events.py | 5 +-- scripts/qapi/gen.py | 14 ++++---- scripts/qapi/introspect.py | 30 ++++++++--------- scripts/qapi/schema.py | 60 +++++++++++++++++++++------------- scripts/qapi/types.py | 33 ++++++++++--------- scripts/qapi/visit.py | 23 ++++++------- tests/qapi-schema/test-qapi.py | 4 +-- 9 files changed, 100 insertions(+), 83 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index 87c67ab23f..0eac3308b2 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -116,7 +116,7 @@ def _nodes_for_ifcond(self, ifcond, with_if=3DTrue): the conditions are in literal-text and the commas are not. If with_if is False, we don't return the "(If: " and ")". """ - condlist =3D intersperse([nodes.literal('', c) for c in ifcond], + condlist =3D intersperse([nodes.literal('', c) for c in ifcond.ifc= ond], nodes.Text(', ')) if not with_if: return condlist @@ -139,7 +139,7 @@ def _nodes_for_one_member(self, member): term.append(nodes.literal('', member.type.doc_type())) if member.optional: term.append(nodes.Text(' (optional)')) - if member.ifcond: + if member.ifcond.ifcond: term.extend(self._nodes_for_ifcond(member.ifcond)) return term =20 @@ -154,7 +154,7 @@ def _nodes_for_variant_when(self, variants, variant): nodes.literal('', variants.tag_member.name), nodes.Text(' is '), nodes.literal('', '"%s"' % variant.name)] - if variant.ifcond: + if variant.ifcond.ifcond: term.extend(self._nodes_for_ifcond(variant.ifcond)) return term =20 @@ -209,7 +209,7 @@ def _nodes_for_enum_values(self, doc): dlnode =3D nodes.definition_list() for section in doc.args.values(): termtext =3D [nodes.literal('', section.member.name)] - if section.member.ifcond: + if section.member.ifcond.ifcond: termtext.extend(self._nodes_for_ifcond(section.member.ifco= nd)) # TODO drop fallbacks when undocumented members are outlawed if section.text: @@ -277,7 +277,7 @@ def _nodes_for_sections(self, doc): def _nodes_for_if_section(self, ifcond): """Return list of doctree nodes for the "If" section""" nodelist =3D [] - if ifcond: + if ifcond.ifcond: snode =3D self._make_section('If') snode +=3D nodes.paragraph( '', '', *self._nodes_for_ifcond(ifcond, with_if=3DFalse) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 0e13d51054..3654825968 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -17,7 +17,6 @@ Dict, List, Optional, - Sequence, Set, ) =20 @@ -31,6 +30,7 @@ from .schema import ( QAPISchema, QAPISchemaFeature, + QAPISchemaIfCond, QAPISchemaObjectType, QAPISchemaType, ) @@ -301,7 +301,7 @@ def visit_end(self) -> None: def visit_command(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], arg_type: Optional[QAPISchemaObjectType], ret_type: Optional[QAPISchemaType], diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index fee8c671e7..82475e84ec 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,7 +12,7 @@ See the COPYING file in the top-level directory. """ =20 -from typing import List, Optional, Sequence +from typing import List, Optional =20 from .common import c_enum_const, c_name, mcgen from .gen import QAPISchemaModularCVisitor, build_params, ifcontext @@ -20,6 +20,7 @@ QAPISchema, QAPISchemaEnumMember, QAPISchemaFeature, + QAPISchemaIfCond, QAPISchemaObjectType, ) from .source import QAPISourceInfo @@ -227,7 +228,7 @@ def visit_end(self) -> None: def visit_event(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], arg_type: Optional[QAPISchemaObjectType], boxed: bool) -> None: diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 1fa503bdbd..1c5b190276 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -18,7 +18,6 @@ Dict, Iterator, Optional, - Sequence, Tuple, ) =20 @@ -32,6 +31,7 @@ mcgen, ) from .schema import ( + QAPISchemaIfCond, QAPISchemaModule, QAPISchemaObjectType, QAPISchemaVisitor, @@ -85,7 +85,7 @@ def write(self, output_dir: str) -> None: fp.write(text) =20 =20 -def _wrap_ifcond(ifcond: Sequence[str], before: str, after: str) -> str: +def _wrap_ifcond(ifcond: QAPISchemaIfCond, before: str, after: str) -> str: if before =3D=3D after: return after # suppress empty #if ... #endif =20 @@ -95,9 +95,9 @@ def _wrap_ifcond(ifcond: Sequence[str], before: str, afte= r: str) -> str: if added[0] =3D=3D '\n': out +=3D '\n' added =3D added[1:] - out +=3D gen_if(ifcond) + out +=3D gen_if(ifcond.ifcond) out +=3D added - out +=3D gen_endif(ifcond) + out +=3D gen_endif(ifcond.ifcond) return out =20 =20 @@ -127,9 +127,9 @@ def build_params(arg_type: Optional[QAPISchemaObjectTyp= e], class QAPIGenCCode(QAPIGen): def __init__(self, fname: str): super().__init__(fname) - self._start_if: Optional[Tuple[Sequence[str], str, str]] =3D None + self._start_if: Optional[Tuple[QAPISchemaIfCond, str, str]] =3D No= ne =20 - def start_if(self, ifcond: Sequence[str]) -> None: + def start_if(self, ifcond: QAPISchemaIfCond) -> None: assert self._start_if is None self._start_if =3D (ifcond, self._body, self._preamble) =20 @@ -187,7 +187,7 @@ def _bottom(self) -> str: =20 =20 @contextmanager -def ifcontext(ifcond: Sequence[str], *args: QAPIGenCCode) -> Iterator[None= ]: +def ifcontext(ifcond: QAPISchemaIfCond, *args: QAPIGenCCode) -> Iterator[N= one]: """ A with-statement context manager that wraps with `start_if()` / `end_i= f()`. =20 diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 9a348ca2e5..db1ebbf53a 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -15,11 +15,9 @@ Any, Dict, Generic, - Iterable, List, Optional, Sequence, - Tuple, TypeVar, Union, ) @@ -38,6 +36,7 @@ QAPISchemaEntity, QAPISchemaEnumMember, QAPISchemaFeature, + QAPISchemaIfCond, QAPISchemaObjectType, QAPISchemaObjectTypeMember, QAPISchemaType, @@ -91,11 +90,11 @@ class Annotated(Generic[_ValueT]): """ # TODO: Remove after Python 3.7 adds @dataclass: # pylint: disable=3Dtoo-few-public-methods - def __init__(self, value: _ValueT, ifcond: Iterable[str], + def __init__(self, value: _ValueT, ifcond: QAPISchemaIfCond, comment: Optional[str] =3D None): self.value =3D value self.comment: Optional[str] =3D comment - self.ifcond: Tuple[str, ...] =3D tuple(ifcond) + self.ifcond =3D ifcond =20 =20 def _tree_to_qlit(obj: JSONValue, @@ -124,11 +123,11 @@ def indent(level: int) -> str: ret =3D '' if obj.comment: ret +=3D indent(level) + f"/* {obj.comment} */\n" - if obj.ifcond: - ret +=3D gen_if(obj.ifcond) + if obj.ifcond.ifcond: + ret +=3D gen_if(obj.ifcond.ifcond) ret +=3D _tree_to_qlit(obj.value, level) - if obj.ifcond: - ret +=3D '\n' + gen_endif(obj.ifcond) + if obj.ifcond.ifcond: + ret +=3D '\n' + gen_endif(obj.ifcond.ifcond) return ret =20 ret =3D '' @@ -254,7 +253,7 @@ def _gen_features(features: Sequence[QAPISchemaFeature] return [Annotated(f.name, f.ifcond) for f in features] =20 def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object], - ifcond: Sequence[str] =3D (), + ifcond: QAPISchemaIfCond =3D QAPISchemaIfCond(), features: Sequence[QAPISchemaFeature] =3D ()) -> None: """ Build and append a SchemaInfo object to self._trees. @@ -305,7 +304,7 @@ def visit_builtin_type(self, name: str, info: Optional[= QAPISourceInfo], self._gen_tree(name, 'builtin', {'json-type': json_type}) =20 def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaEnumMember], prefix: Optional[str]) -> None: @@ -316,14 +315,14 @@ def visit_enum_type(self, name: str, info: Optional[Q= APISourceInfo], ) =20 def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: element =3D self._use_type(element_type) self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond) =20 def visit_object_type_flat(self, name: str, info: Optional[QAPISourceI= nfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], variants: Optional[QAPISchemaVariants]) -> = None: @@ -336,7 +335,7 @@ def visit_object_type_flat(self, name: str, info: Optio= nal[QAPISourceInfo], self._gen_tree(name, 'object', obj, ifcond, features) =20 def visit_alternate_type(self, name: str, info: Optional[QAPISourceInf= o], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], variants: QAPISchemaVariants) -> None: self._gen_tree( @@ -348,7 +347,7 @@ def visit_alternate_type(self, name: str, info: Optiona= l[QAPISourceInfo], ) =20 def visit_command(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], arg_type: Optional[QAPISchemaObjectType], ret_type: Optional[QAPISchemaType], gen: bool, @@ -367,7 +366,8 @@ def visit_command(self, name: str, info: Optional[QAPIS= ourceInfo], self._gen_tree(name, 'command', obj, ifcond, features) =20 def visit_event(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], features: List[QAPISchemaFeatur= e], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], arg_type: Optional[QAPISchemaObjectType], boxed: bool) -> None: assert self._schema is not None diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a4ce3972a4..e3beb24500 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -25,6 +25,11 @@ from .parser import QAPISchemaParser =20 =20 +class QAPISchemaIfCond: + def __init__(self, ifcond=3DNone): + self.ifcond =3D ifcond or [] + + class QAPISchemaEntity: meta: Optional[str] =3D None =20 @@ -42,7 +47,7 @@ def __init__(self, name: str, info, doc, ifcond=3DNone, f= eatures=3DNone): # such place). self.info =3D info self.doc =3D doc - self._ifcond =3D ifcond or [] + self._ifcond =3D ifcond or QAPISchemaIfCond() self.features =3D features or [] self._checked =3D False =20 @@ -593,7 +598,7 @@ def check(self, schema, seen): self.info, "discriminator member '%s' of %s must not be optional" % (self._tag_name, base)) - if self.tag_member.ifcond: + if self.tag_member.ifcond.ifcond: raise QAPISemError( self.info, "discriminator member '%s' of %s must not be condition= al" @@ -601,7 +606,7 @@ def check(self, schema, seen): else: # simple union assert isinstance(self.tag_member.type, QAPISchemaEnumType) assert not self.tag_member.optional - assert self.tag_member.ifcond =3D=3D [] + assert self.tag_member.ifcond.ifcond =3D=3D [] if self._tag_name: # flat union # branches that are not explicitly covered get an empty type cases =3D {v.name for v in self.variants} @@ -646,7 +651,7 @@ def __init__(self, name, info, ifcond=3DNone): assert isinstance(name, str) self.name =3D name self.info =3D info - self.ifcond =3D ifcond or [] + self.ifcond =3D ifcond or QAPISchemaIfCond() self.defined_in =3D None =20 def set_defined_in(self, name): @@ -968,11 +973,13 @@ def _def_predefineds(self): def _make_features(self, features, info): if features is None: return [] - return [QAPISchemaFeature(f['name'], info, f.get('if')) + return [QAPISchemaFeature(f['name'], info, + QAPISchemaIfCond(f.get('if'))) for f in features] =20 def _make_enum_members(self, values, info): - return [QAPISchemaEnumMember(v['name'], info, v.get('if')) + return [QAPISchemaEnumMember(v['name'], info, + QAPISchemaIfCond(v.get('if'))) for v in values] =20 def _make_implicit_enum_type(self, name, info, ifcond, values): @@ -1018,7 +1025,7 @@ def _def_enum_type(self, expr, info, doc): name =3D expr['enum'] data =3D expr['data'] prefix =3D expr.get('prefix') - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) self._def_entity(QAPISchemaEnumType( name, info, doc, ifcond, features, @@ -1036,7 +1043,8 @@ def _make_member(self, name, typ, ifcond, features, i= nfo): self._make_features(features, in= fo)) =20 def _make_members(self, data, info): - return [self._make_member(key, value['type'], value.get('if'), + return [self._make_member(key, value['type'], + QAPISchemaIfCond(value.get('if')), value.get('features'), info) for (key, value) in data.items()] =20 @@ -1044,7 +1052,7 @@ def _def_struct_type(self, expr, info, doc): name =3D expr['struct'] base =3D expr.get('base') data =3D expr['data'] - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) self._def_entity(QAPISchemaObjectType( name, info, doc, ifcond, features, base, @@ -1067,7 +1075,7 @@ def _def_union_type(self, expr, info, doc): name =3D expr['union'] data =3D expr['data'] base =3D expr.get('base') - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) tag_name =3D expr.get('discriminator') tag_member =3D None @@ -1076,15 +1084,19 @@ def _def_union_type(self, expr, info, doc): name, info, ifcond, 'base', self._make_members(base, info)) if tag_name: - variants =3D [self._make_variant(key, value['type'], - value.get('if'), info) - for (key, value) in data.items()] + variants =3D [ + self._make_variant(key, value['type'], + QAPISchemaIfCond(value.get('if')), + info) + for (key, value) in data.items()] members =3D [] else: - variants =3D [self._make_simple_variant(key, value['type'], - value.get('if'), info) - for (key, value) in data.items()] - enum =3D [{'name': v.name, 'if': v.ifcond} for v in variants] + variants =3D [ + self._make_simple_variant(key, value['type'], + QAPISchemaIfCond(value.get('if')= ), + info) + for (key, value) in data.items()] + enum =3D [{'name': v.name, 'if': v.ifcond.ifcond} for v in var= iants] typ =3D self._make_implicit_enum_type(name, info, ifcond, enum) tag_member =3D QAPISchemaObjectTypeMember('type', info, typ, F= alse) members =3D [tag_member] @@ -1097,11 +1109,13 @@ def _def_union_type(self, expr, info, doc): def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] data =3D expr['data'] - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) - variants =3D [self._make_variant(key, value['type'], value.get('if= '), - info) - for (key, value) in data.items()] + variants =3D [ + self._make_variant(key, value['type'], + QAPISchemaIfCond(value.get('if')), + info) + for (key, value) in data.items()] tag_member =3D QAPISchemaObjectTypeMember('type', info, 'QType', F= alse) self._def_entity( QAPISchemaAlternateType(name, info, doc, ifcond, features, @@ -1118,7 +1132,7 @@ def _def_command(self, expr, info, doc): allow_oob =3D expr.get('allow-oob', False) allow_preconfig =3D expr.get('allow-preconfig', False) coroutine =3D expr.get('coroutine', False) - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( @@ -1137,7 +1151,7 @@ def _def_event(self, expr, info, doc): name =3D expr['event'] data =3D expr.get('data') boxed =3D expr.get('boxed', False) - ifcond =3D expr.get('if') + ifcond =3D QAPISchemaIfCond(expr.get('if')) features =3D self._make_features(expr.get('features'), info) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 20d572a23a..3673cf0f49 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -13,7 +13,7 @@ # See the COPYING file in the top-level directory. """ =20 -from typing import List, Optional, Sequence +from typing import List, Optional =20 from .common import ( c_enum_const, @@ -27,6 +27,7 @@ QAPISchema, QAPISchemaEnumMember, QAPISchemaFeature, + QAPISchemaIfCond, QAPISchemaObjectType, QAPISchemaObjectTypeMember, QAPISchemaType, @@ -50,13 +51,13 @@ def gen_enum_lookup(name: str, ''', c_name=3Dc_name(name)) for memb in members: - ret +=3D gen_if(memb.ifcond) + ret +=3D gen_if(memb.ifcond.ifcond) index =3D c_enum_const(name, memb.name, prefix) ret +=3D mcgen(''' [%(index)s] =3D "%(name)s", ''', index=3Dindex, name=3Dmemb.name) - ret +=3D gen_endif(memb.ifcond) + ret +=3D gen_endif(memb.ifcond.ifcond) =20 ret +=3D mcgen(''' }, @@ -80,12 +81,12 @@ def gen_enum(name: str, c_name=3Dc_name(name)) =20 for memb in enum_members: - ret +=3D gen_if(memb.ifcond) + ret +=3D gen_if(memb.ifcond.ifcond) ret +=3D mcgen(''' %(c_enum)s, ''', c_enum=3Dc_enum_const(name, memb.name, prefix)) - ret +=3D gen_endif(memb.ifcond) + ret +=3D gen_endif(memb.ifcond.ifcond) =20 ret +=3D mcgen(''' } %(c_name)s; @@ -125,7 +126,7 @@ def gen_array(name: str, element_type: QAPISchemaType) = -> str: def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str: ret =3D '' for memb in members: - ret +=3D gen_if(memb.ifcond) + ret +=3D gen_if(memb.ifcond.ifcond) if memb.optional: ret +=3D mcgen(''' bool has_%(c_name)s; @@ -135,11 +136,11 @@ def gen_struct_members(members: List[QAPISchemaObject= TypeMember]) -> str: %(c_type)s %(c_name)s; ''', c_type=3Dmemb.type.c_type(), c_name=3Dc_name(memb.nam= e)) - ret +=3D gen_endif(memb.ifcond) + ret +=3D gen_endif(memb.ifcond.ifcond) return ret =20 =20 -def gen_object(name: str, ifcond: Sequence[str], +def gen_object(name: str, ifcond: QAPISchemaIfCond, base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], variants: Optional[QAPISchemaVariants]) -> str: @@ -158,7 +159,7 @@ def gen_object(name: str, ifcond: Sequence[str], ret +=3D mcgen(''' =20 ''') - ret +=3D gen_if(ifcond) + ret +=3D gen_if(ifcond.ifcond) ret +=3D mcgen(''' struct %(c_name)s { ''', @@ -192,7 +193,7 @@ def gen_object(name: str, ifcond: Sequence[str], ret +=3D mcgen(''' }; ''') - ret +=3D gen_endif(ifcond) + ret +=3D gen_endif(ifcond.ifcond) =20 return ret =20 @@ -219,13 +220,13 @@ def gen_variants(variants: QAPISchemaVariants) -> str: for var in variants.variants: if var.type.name =3D=3D 'q_empty': continue - ret +=3D gen_if(var.ifcond) + ret +=3D gen_if(var.ifcond.ifcond) ret +=3D mcgen(''' %(c_type)s %(c_name)s; ''', c_type=3Dvar.type.c_unboxed_type(), c_name=3Dc_name(var.name)) - ret +=3D gen_endif(var.ifcond) + ret +=3D gen_endif(var.ifcond.ifcond) =20 ret +=3D mcgen(''' } u; @@ -307,7 +308,7 @@ def _gen_type_cleanup(self, name: str) -> None: def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaEnumMember], prefix: Optional[str]) -> None: @@ -318,7 +319,7 @@ def visit_enum_type(self, def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.preamble_add(gen_fwd_object_or_array(name)) @@ -328,7 +329,7 @@ def visit_array_type(self, def visit_object_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], @@ -351,7 +352,7 @@ def visit_object_type(self, def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], variants: QAPISchemaVariants) -> None: with ifcontext(ifcond, self._genh): diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 9e96f3c566..67721b2470 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -13,7 +13,7 @@ See the COPYING file in the top-level directory. """ =20 -from typing import List, Optional, Sequence +from typing import List, Optional =20 from .common import ( c_enum_const, @@ -29,6 +29,7 @@ QAPISchemaEnumMember, QAPISchemaEnumType, QAPISchemaFeature, + QAPISchemaIfCond, QAPISchemaObjectType, QAPISchemaObjectTypeMember, QAPISchemaType, @@ -78,7 +79,7 @@ def gen_visit_object_members(name: str, =20 for memb in members: deprecated =3D 'deprecated' in [f.name for f in memb.features] - ret +=3D gen_if(memb.ifcond) + ret +=3D gen_if(memb.ifcond.ifcond) if memb.optional: ret +=3D mcgen(''' if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) { @@ -111,7 +112,7 @@ def gen_visit_object_members(name: str, ret +=3D mcgen(''' } ''') - ret +=3D gen_endif(memb.ifcond) + ret +=3D gen_endif(memb.ifcond.ifcond) =20 if variants: tag_member =3D variants.tag_member @@ -125,7 +126,7 @@ def gen_visit_object_members(name: str, for var in variants.variants: case_str =3D c_enum_const(tag_member.type.name, var.name, tag_member.type.prefix) - ret +=3D gen_if(var.ifcond) + ret +=3D gen_if(var.ifcond.ifcond) if var.type.name =3D=3D 'q_empty': # valid variant and nothing to do ret +=3D mcgen(''' @@ -141,7 +142,7 @@ def gen_visit_object_members(name: str, case=3Dcase_str, c_type=3Dvar.type.c_name(), c_name=3Dc_name(v= ar.name)) =20 - ret +=3D gen_endif(var.ifcond) + ret +=3D gen_endif(var.ifcond.ifcond) ret +=3D mcgen(''' default: abort(); @@ -227,7 +228,7 @@ def gen_visit_alternate(name: str, variants: QAPISchema= Variants) -> str: c_name=3Dc_name(name)) =20 for var in variants.variants: - ret +=3D gen_if(var.ifcond) + ret +=3D gen_if(var.ifcond.ifcond) ret +=3D mcgen(''' case %(case)s: ''', @@ -253,7 +254,7 @@ def gen_visit_alternate(name: str, variants: QAPISchema= Variants) -> str: ret +=3D mcgen(''' break; ''') - ret +=3D gen_endif(var.ifcond) + ret +=3D gen_endif(var.ifcond.ifcond) =20 ret +=3D mcgen(''' case QTYPE_NONE: @@ -352,7 +353,7 @@ def _begin_user_module(self, name: str) -> None: def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaEnumMember], prefix: Optional[str]) -> None: @@ -363,7 +364,7 @@ def visit_enum_type(self, def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) @@ -372,7 +373,7 @@ def visit_array_type(self, def visit_object_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], @@ -394,7 +395,7 @@ def visit_object_type(self, def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], - ifcond: Sequence[str], + ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], variants: QAPISchemaVariants) -> None: with ifcontext(ifcond, self._genh, self._genc): diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index f1c4deb9a5..7907b4ac3a 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -94,8 +94,8 @@ def _print_variants(variants): =20 @staticmethod def _print_if(ifcond, indent=3D4): - if ifcond: - print('%sif %s' % (' ' * indent, ifcond)) + if ifcond.ifcond: + print('%sif %s' % (' ' * indent, ifcond.ifcond)) =20 @classmethod def _print_features(cls, features, indent=3D4): --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629982046; cv=none; d=zohomail.com; s=zohoarc; b=anvjdp83UxPdMnMPoWzWyk/JnGt3NtvImDK8D3omyL43QEkLGMbIcf3TjjjSwjUczpNbEnf9CZzYz+VihJX1fLI4Eyr8CNuM0rg/iCQJ2bp8RbblmeeqVYnnxCXatWAGCTDUErm5MwFbXKP4LnPHOY0Hai1TEhvRGY2EUjr/ct8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629982046; 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=IMmHfnyOmMsk7BhYFYFe/otc4xTJVHv/UwhBETXvLkA=; b=VvFRMtk46HFiUdAYmZ+vOphYm6BdnWzzvV82zdVmnwtzMYg66rVOdqcxjCDngBSVXEfOJUlnaJt9zgSq42ukkV/O51f5rFyPdsHpM08ljiuWsVpoOYF3/yKtvNVY5JWzYhTwTZBRUU8Jcieb2EuaOiEw4bbq4Rv1EQfN6Rji998= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629982046570570.0251652939953; Thu, 26 Aug 2021 05:47:26 -0700 (PDT) Received: from localhost ([::1]:45642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEmz-0004vv-75 for importer@patchew.org; Thu, 26 Aug 2021 08:47:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYl-0004Af-QT for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYh-0008C7-Ro for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:43 -0400 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-544-8icpL8bWPoKssPoLx24uOg-1; Thu, 26 Aug 2021 08:32:32 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 374731008064; Thu, 26 Aug 2021 12:32:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 043BD60622; Thu, 26 Aug 2021 12:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A378F11380B7; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981157; 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=IMmHfnyOmMsk7BhYFYFe/otc4xTJVHv/UwhBETXvLkA=; b=Lb4E6FJzdxCagi8Y4L3F1rpmopjP0L8FZreWcSfJmCtBrILeZ8g5PZgjUndyUDvkXk/LXO qMTxupmCRnLoAX0iYsT0qM0oh2F8raaxWIc48E70ePZ+PA3ffSyIjdaZC7Ld8PlIYlZsL/ Wo5uTP8JH6I+p91xxPAXmQBD7zVKxaY= X-MC-Unique: 8icpL8bWPoKssPoLx24uOg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 04/11] qapi: add QAPISchemaIfCond.is_present() Date: Thu, 26 Aug 2021 14:32:18 +0200 Message-Id: <20210826123225.157891-5-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629982047421100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20210804083105.97531-4-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster --- docs/sphinx/qapidoc.py | 8 ++++---- scripts/qapi/introspect.py | 4 ++-- scripts/qapi/schema.py | 7 +++++-- tests/qapi-schema/test-qapi.py | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index 0eac3308b2..511520f33f 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -139,7 +139,7 @@ def _nodes_for_one_member(self, member): term.append(nodes.literal('', member.type.doc_type())) if member.optional: term.append(nodes.Text(' (optional)')) - if member.ifcond.ifcond: + if member.ifcond.is_present(): term.extend(self._nodes_for_ifcond(member.ifcond)) return term =20 @@ -154,7 +154,7 @@ def _nodes_for_variant_when(self, variants, variant): nodes.literal('', variants.tag_member.name), nodes.Text(' is '), nodes.literal('', '"%s"' % variant.name)] - if variant.ifcond.ifcond: + if variant.ifcond.is_present(): term.extend(self._nodes_for_ifcond(variant.ifcond)) return term =20 @@ -209,7 +209,7 @@ def _nodes_for_enum_values(self, doc): dlnode =3D nodes.definition_list() for section in doc.args.values(): termtext =3D [nodes.literal('', section.member.name)] - if section.member.ifcond.ifcond: + if section.member.ifcond.is_present(): termtext.extend(self._nodes_for_ifcond(section.member.ifco= nd)) # TODO drop fallbacks when undocumented members are outlawed if section.text: @@ -277,7 +277,7 @@ def _nodes_for_sections(self, doc): def _nodes_for_if_section(self, ifcond): """Return list of doctree nodes for the "If" section""" nodelist =3D [] - if ifcond.ifcond: + if ifcond.is_present(): snode =3D self._make_section('If') snode +=3D nodes.paragraph( '', '', *self._nodes_for_ifcond(ifcond, with_if=3DFalse) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index db1ebbf53a..e23725e2f9 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -123,10 +123,10 @@ def indent(level: int) -> str: ret =3D '' if obj.comment: ret +=3D indent(level) + f"/* {obj.comment} */\n" - if obj.ifcond.ifcond: + if obj.ifcond.is_present(): ret +=3D gen_if(obj.ifcond.ifcond) ret +=3D _tree_to_qlit(obj.value, level) - if obj.ifcond.ifcond: + if obj.ifcond.is_present(): ret +=3D '\n' + gen_endif(obj.ifcond.ifcond) return ret =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index e3beb24500..86fcd6cbd5 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -29,6 +29,9 @@ class QAPISchemaIfCond: def __init__(self, ifcond=3DNone): self.ifcond =3D ifcond or [] =20 + def is_present(self): + return bool(self.ifcond) + =20 class QAPISchemaEntity: meta: Optional[str] =3D None @@ -598,7 +601,7 @@ def check(self, schema, seen): self.info, "discriminator member '%s' of %s must not be optional" % (self._tag_name, base)) - if self.tag_member.ifcond.ifcond: + if self.tag_member.ifcond.is_present(): raise QAPISemError( self.info, "discriminator member '%s' of %s must not be condition= al" @@ -606,7 +609,7 @@ def check(self, schema, seen): else: # simple union assert isinstance(self.tag_member.type, QAPISchemaEnumType) assert not self.tag_member.optional - assert self.tag_member.ifcond.ifcond =3D=3D [] + assert not self.tag_member.ifcond.is_present() if self._tag_name: # flat union # branches that are not explicitly covered get an empty type cases =3D {v.name for v in self.variants} diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 7907b4ac3a..c92be2d086 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -94,7 +94,7 @@ def _print_variants(variants): =20 @staticmethod def _print_if(ifcond, indent=3D4): - if ifcond.ifcond: + if ifcond.is_present(): print('%sif %s' % (' ' * indent, ifcond.ifcond)) =20 @classmethod --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629982224; cv=none; d=zohomail.com; s=zohoarc; b=CaTAc7dXaQSpbvWfXNR0qisWJoN5Zkf2eCcfguThJ3gBEAkMSMVlUw1x1tHBSo/mSTRAsnStdDIPNydO1F7XWzb3ozfkv9VKPlMCi3FKw6sBB3Yl+RScHmtGJnPU3BXYkleLP1w+DIX8T468I/GsIy9XvKMkeOmO334VmCIvIB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629982224; 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=tIMCAFus5h3/DOyji5ypTxBw6l9f+mDSvJBQI0WXow8=; b=gFPTllpVyK+rSK+kkH6bs+RmwklOiHF5pfNuWoGdnOtxA+wjASt1ZrwM3OylVtTXNdZFoBPXwSWAKCIhfuzmhIwl8CxRX7Ye5jbXb2UsY0b3XWFhzm0VrJe6RKm+kfpKKw/hoED8Wkcpe617rHqGRDA/3r+g92Lu0735HJZGDgY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629982224636866.609409141615; Thu, 26 Aug 2021 05:50:24 -0700 (PDT) Received: from localhost ([::1]:51428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEpr-0000PK-I3 for importer@patchew.org; Thu, 26 Aug 2021 08:50:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYx-0004E7-Jx for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYj-0008E5-Qp for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:55 -0400 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-330-mm7X8RUeNiSykpmoAEcI6g-1; Thu, 26 Aug 2021 08:32:32 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38B8B6409B; Thu, 26 Aug 2021 12:32:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD2F860D31; Thu, 26 Aug 2021 12:32:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A6E6B11380B8; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981161; 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=tIMCAFus5h3/DOyji5ypTxBw6l9f+mDSvJBQI0WXow8=; b=aHaOnv1x8NEiINCBlcPFGTM85CyJbNf7Vfd1T5V+d3N/81hLobATVnEHD7gz3KwXrrVMrd +Lm3BJ4ZhHnbPMf+JvfPvh5uym7M1JhU6D0qXk6iNmiVJ4AaGTYhvBsQyL4IAv9/MsTkjI TaCUaGFOIh5UrH07hNvKSivdzGb86K4= X-MC-Unique: mm7X8RUeNiSykpmoAEcI6g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/11] qapi: introduce QAPISchemaIfCond.cgen() Date: Thu, 26 Aug 2021 14:32:19 +0200 Message-Id: <20210826123225.157891-6-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629982226406100001 From: Marc-Andr=C3=A9 Lureau Instead of building prepocessor conditions from a list of string, use the result generated from QAPISchemaIfCond.cgen() and hide the implementation details. Note: this patch introduces a minor regression, generating a redundant pair of parenthesis. This is mostly fixed in a later patch in this series ("qapi: replace if condition list with dict [..]") Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-5-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Commit message tweaked] Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 35 ++++++++++++++++++++++------------- scripts/qapi/gen.py | 4 ++-- scripts/qapi/introspect.py | 4 ++-- scripts/qapi/schema.py | 5 ++++- scripts/qapi/types.py | 20 ++++++++++---------- scripts/qapi/visit.py | 12 ++++++------ 6 files changed, 46 insertions(+), 34 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 6ad1eeb61d..ba9fe14e4b 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -12,7 +12,12 @@ # See the COPYING file in the top-level directory. =20 import re -from typing import Match, Optional, Sequence +from typing import ( + List, + Match, + Optional, + Union, +) =20 =20 #: Magic string that gets removed along with all space to its right. @@ -194,22 +199,26 @@ def guardend(name: str) -> str: name=3Dc_fname(name).upper()) =20 =20 -def gen_if(ifcond: Sequence[str]) -> str: - ret =3D '' - for ifc in ifcond: - ret +=3D mcgen(''' +def cgen_ifcond(ifcond: Union[str, List[str]]) -> str: + if not ifcond: + return '' + return '(' + ') && ('.join(ifcond) + ')' + + +def gen_if(cond: str) -> str: + if not cond: + return '' + return mcgen(''' #if %(cond)s -''', cond=3Difc) - return ret +''', cond=3Dcond) =20 =20 -def gen_endif(ifcond: Sequence[str]) -> str: - ret =3D '' - for ifc in reversed(ifcond): - ret +=3D mcgen(''' +def gen_endif(cond: str) -> str: + if not cond: + return '' + return mcgen(''' #endif /* %(cond)s */ -''', cond=3Difc) - return ret +''', cond=3Dcond) =20 =20 def must_match(pattern: str, string: str) -> Match[str]: diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 1c5b190276..51a597a025 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -95,9 +95,9 @@ def _wrap_ifcond(ifcond: QAPISchemaIfCond, before: str, a= fter: str) -> str: if added[0] =3D=3D '\n': out +=3D '\n' added =3D added[1:] - out +=3D gen_if(ifcond.ifcond) + out +=3D gen_if(ifcond.cgen()) out +=3D added - out +=3D gen_endif(ifcond.ifcond) + out +=3D gen_endif(ifcond.cgen()) return out =20 =20 diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index e23725e2f9..bd4233ecee 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -124,10 +124,10 @@ def indent(level: int) -> str: if obj.comment: ret +=3D indent(level) + f"/* {obj.comment} */\n" if obj.ifcond.is_present(): - ret +=3D gen_if(obj.ifcond.ifcond) + ret +=3D gen_if(obj.ifcond.cgen()) ret +=3D _tree_to_qlit(obj.value, level) if obj.ifcond.is_present(): - ret +=3D '\n' + gen_endif(obj.ifcond.ifcond) + ret +=3D '\n' + gen_endif(obj.ifcond.cgen()) return ret =20 ret =3D '' diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 86fcd6cbd5..4ea7e88846 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -19,7 +19,7 @@ import re from typing import Optional =20 -from .common import POINTER_SUFFIX, c_name +from .common import POINTER_SUFFIX, c_name, cgen_ifcond from .error import QAPIError, QAPISemError, QAPISourceError from .expr import check_exprs from .parser import QAPISchemaParser @@ -29,6 +29,9 @@ class QAPISchemaIfCond: def __init__(self, ifcond=3DNone): self.ifcond =3D ifcond or [] =20 + def cgen(self): + return cgen_ifcond(self.ifcond) + def is_present(self): return bool(self.ifcond) =20 diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 3673cf0f49..db9ff95bd1 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -51,13 +51,13 @@ def gen_enum_lookup(name: str, ''', c_name=3Dc_name(name)) for memb in members: - ret +=3D gen_if(memb.ifcond.ifcond) + ret +=3D gen_if(memb.ifcond.cgen()) index =3D c_enum_const(name, memb.name, prefix) ret +=3D mcgen(''' [%(index)s] =3D "%(name)s", ''', index=3Dindex, name=3Dmemb.name) - ret +=3D gen_endif(memb.ifcond.ifcond) + ret +=3D gen_endif(memb.ifcond.cgen()) =20 ret +=3D mcgen(''' }, @@ -81,12 +81,12 @@ def gen_enum(name: str, c_name=3Dc_name(name)) =20 for memb in enum_members: - ret +=3D gen_if(memb.ifcond.ifcond) + ret +=3D gen_if(memb.ifcond.cgen()) ret +=3D mcgen(''' %(c_enum)s, ''', c_enum=3Dc_enum_const(name, memb.name, prefix)) - ret +=3D gen_endif(memb.ifcond.ifcond) + ret +=3D gen_endif(memb.ifcond.cgen()) =20 ret +=3D mcgen(''' } %(c_name)s; @@ -126,7 +126,7 @@ def gen_array(name: str, element_type: QAPISchemaType) = -> str: def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str: ret =3D '' for memb in members: - ret +=3D gen_if(memb.ifcond.ifcond) + ret +=3D gen_if(memb.ifcond.cgen()) if memb.optional: ret +=3D mcgen(''' bool has_%(c_name)s; @@ -136,7 +136,7 @@ def gen_struct_members(members: List[QAPISchemaObjectTy= peMember]) -> str: %(c_type)s %(c_name)s; ''', c_type=3Dmemb.type.c_type(), c_name=3Dc_name(memb.nam= e)) - ret +=3D gen_endif(memb.ifcond.ifcond) + ret +=3D gen_endif(memb.ifcond.cgen()) return ret =20 =20 @@ -159,7 +159,7 @@ def gen_object(name: str, ifcond: QAPISchemaIfCond, ret +=3D mcgen(''' =20 ''') - ret +=3D gen_if(ifcond.ifcond) + ret +=3D gen_if(ifcond.cgen()) ret +=3D mcgen(''' struct %(c_name)s { ''', @@ -193,7 +193,7 @@ def gen_object(name: str, ifcond: QAPISchemaIfCond, ret +=3D mcgen(''' }; ''') - ret +=3D gen_endif(ifcond.ifcond) + ret +=3D gen_endif(ifcond.cgen()) =20 return ret =20 @@ -220,13 +220,13 @@ def gen_variants(variants: QAPISchemaVariants) -> str: for var in variants.variants: if var.type.name =3D=3D 'q_empty': continue - ret +=3D gen_if(var.ifcond.ifcond) + ret +=3D gen_if(var.ifcond.cgen()) ret +=3D mcgen(''' %(c_type)s %(c_name)s; ''', c_type=3Dvar.type.c_unboxed_type(), c_name=3Dc_name(var.name)) - ret +=3D gen_endif(var.ifcond.ifcond) + ret +=3D gen_endif(var.ifcond.cgen()) =20 ret +=3D mcgen(''' } u; diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 67721b2470..56ea516399 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -79,7 +79,7 @@ def gen_visit_object_members(name: str, =20 for memb in members: deprecated =3D 'deprecated' in [f.name for f in memb.features] - ret +=3D gen_if(memb.ifcond.ifcond) + ret +=3D gen_if(memb.ifcond.cgen()) if memb.optional: ret +=3D mcgen(''' if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) { @@ -112,7 +112,7 @@ def gen_visit_object_members(name: str, ret +=3D mcgen(''' } ''') - ret +=3D gen_endif(memb.ifcond.ifcond) + ret +=3D gen_endif(memb.ifcond.cgen()) =20 if variants: tag_member =3D variants.tag_member @@ -126,7 +126,7 @@ def gen_visit_object_members(name: str, for var in variants.variants: case_str =3D c_enum_const(tag_member.type.name, var.name, tag_member.type.prefix) - ret +=3D gen_if(var.ifcond.ifcond) + ret +=3D gen_if(var.ifcond.cgen()) if var.type.name =3D=3D 'q_empty': # valid variant and nothing to do ret +=3D mcgen(''' @@ -142,7 +142,7 @@ def gen_visit_object_members(name: str, case=3Dcase_str, c_type=3Dvar.type.c_name(), c_name=3Dc_name(v= ar.name)) =20 - ret +=3D gen_endif(var.ifcond.ifcond) + ret +=3D gen_endif(var.ifcond.cgen()) ret +=3D mcgen(''' default: abort(); @@ -228,7 +228,7 @@ def gen_visit_alternate(name: str, variants: QAPISchema= Variants) -> str: c_name=3Dc_name(name)) =20 for var in variants.variants: - ret +=3D gen_if(var.ifcond.ifcond) + ret +=3D gen_if(var.ifcond.cgen()) ret +=3D mcgen(''' case %(case)s: ''', @@ -254,7 +254,7 @@ def gen_visit_alternate(name: str, variants: QAPISchema= Variants) -> str: ret +=3D mcgen(''' break; ''') - ret +=3D gen_endif(var.ifcond.ifcond) + ret +=3D gen_endif(var.ifcond.cgen()) =20 ret +=3D mcgen(''' case QTYPE_NONE: --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981537; cv=none; d=zohomail.com; s=zohoarc; b=IeIqvlOlgJzi8JUR7qky2Y1OzY2yZ39uNDNFNiO5v0q5H8bAnhKWVejLLpCOMHK/yB64x7hnw4sXe1jkZEkqOuAzEctB2TetZmWucHkT4WzTpSPAjlATR6bmpdEhURH/+M0ZifZiBaEZ6qWUKcOtg8EDsfc/EGJ5tOpjApXV0KA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981537; 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=V1+I+ZEjd1RdE1fUCXAXh/uFGkFrTb3/VKlu+KCr0xc=; b=hGVM6no6ShSpSfxCBLfkt7c8yfTAlUo7APtWOk28A1AH5VG9IWKikxSoHp00BH1kj7D6Sr7uncReJ1eF4c+HWsnwH2b1hNmM4MUyaongiRFcBOHVhtndPbb1Vaw3qSnUiRZAm9YlOySS+BQ0P4/mrTAQ3SBkyjJcou2Up9vBa3s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981537471135.14237392826794; Thu, 26 Aug 2021 05:38:57 -0700 (PDT) Received: from localhost ([::1]:58730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEem-00030u-Ge for importer@patchew.org; Thu, 26 Aug 2021 08:38:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYm-0004Aj-D7 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYh-0008Bc-UD for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:44 -0400 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-388-6hBjrGc2NzaBHi2Q-Yl58w-1; Thu, 26 Aug 2021 08:32:33 -0400 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 63DE61008065; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCDD160583; Thu, 26 Aug 2021 12:32:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AA35A11380B9; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981154; 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=V1+I+ZEjd1RdE1fUCXAXh/uFGkFrTb3/VKlu+KCr0xc=; b=K1FWrG17vZslsZfiqs2toben1y2stKGkGlr8zUajg07tZ8PURp5nC68yxylHuj37CMVyCu Ib36pxtVI9WFD3Q6L9bbr9GE7qp2NM9x2bWIWOUooFjGLnAQboMAQdFhOkeg3Af7seMcNv 1NxhCssQpiI9IvLiAgqpob7W4Y3NtbA= X-MC-Unique: 6hBjrGc2NzaBHi2Q-Yl58w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 06/11] qapidoc: introduce QAPISchemaIfCond.docgen() Date: Thu, 26 Aug 2021 14:32:20 +0200 Message-Id: <20210826123225.157891-7-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981537957100002 From: Marc-Andr=C3=A9 Lureau Instead of building the condition documentation from a list of string, use the result generated from QAPISchemaIfCond.docgen(). This changes the generated documentation from: - COND1, COND2... (where COND1, COND2 are Literal nodes, and ',' is Text) to: - COND1 and COND2 (the whole string as a Literal node) This will allow us to generate more complex conditions in the following patches, such as "(COND1 and COND2) or COND3". Adding back the differentiated formatting is left to the wish list. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-6-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [TODO comment added] Signed-off-by: Markus Armbruster --- docs/sphinx/qapidoc.py | 14 ++++++++------ scripts/qapi/common.py | 7 +++++++ scripts/qapi/schema.py | 10 +++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index 511520f33f..d791b59492 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -112,17 +112,19 @@ def _make_section(self, title): def _nodes_for_ifcond(self, ifcond, with_if=3DTrue): """Return list of Text, literal nodes for the ifcond =20 - Return a list which gives text like ' (If: cond1, cond2, cond3)', = where - the conditions are in literal-text and the commas are not. + Return a list which gives text like ' (If: condition)'. If with_if is False, we don't return the "(If: " and ")". """ - condlist =3D intersperse([nodes.literal('', c) for c in ifcond.ifc= ond], - nodes.Text(', ')) + + doc =3D ifcond.docgen() + if not doc: + return [] + doc =3D nodes.literal('', doc) if not with_if: - return condlist + return [doc] =20 nodelist =3D [nodes.Text(' ('), nodes.strong('', 'If: ')] - nodelist.extend(condlist) + nodelist.append(doc) nodelist.append(nodes.Text(')')) return nodelist =20 diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index ba9fe14e4b..ddc54e4368 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -205,6 +205,13 @@ def cgen_ifcond(ifcond: Union[str, List[str]]) -> str: return '(' + ') && ('.join(ifcond) + ')' =20 =20 +def docgen_ifcond(ifcond: Union[str, List[str]]) -> str: + # TODO Doc generated for conditions needs polish + if not ifcond: + return '' + return ' and '.join(ifcond) + + def gen_if(cond: str) -> str: if not cond: return '' diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 4ea7e88846..a9345af7b7 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -19,7 +19,12 @@ import re from typing import Optional =20 -from .common import POINTER_SUFFIX, c_name, cgen_ifcond +from .common import ( + POINTER_SUFFIX, + c_name, + cgen_ifcond, + docgen_ifcond, +) from .error import QAPIError, QAPISemError, QAPISourceError from .expr import check_exprs from .parser import QAPISchemaParser @@ -32,6 +37,9 @@ def __init__(self, ifcond=3DNone): def cgen(self): return cgen_ifcond(self.ifcond) =20 + def docgen(self): + return docgen_ifcond(self.ifcond) + def is_present(self): return bool(self.ifcond) =20 --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981877; cv=none; d=zohomail.com; s=zohoarc; b=I03X58Br6vEUqtK8kBo5d8Yfabjr1e0BogCImFYXdMOreMl+SHBS19cgucLWjiSKp+7gBZGajTopyoYWcWQHmzVW3r78xlY61xuUNSLJdxNuEAKXBES/QG4F9rMgC9e27NAtnd1E64sCu4GFWmzQThiGUbe5HLFrtZfsHAr5SPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981877; 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=TeXbrMH6GEOkczvD8QINt/Y6SSvMVYn4yrLCzZqfwos=; b=YZIkk54CGeIk++hEIOaI6u9ZgSxuxae6l2Wnv1lmkca6rJmLTgUd/oVg8MFxmhHiky4WZV+HSQpHX1JAUk0Bt7wOZrmcONKdY9fRqBjFSeCKW6pb1oAXiUHmJpGtHACKh2zK85LFpkEN8IMvJmhBzczhZ0DD5C+LaIawLF0VMzg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981877005638.6058991748575; Thu, 26 Aug 2021 05:44:37 -0700 (PDT) Received: from localhost ([::1]:41390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEkF-0001zh-Sv for importer@patchew.org; Thu, 26 Aug 2021 08:44:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYq-0004Au-6F for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYh-0008Bj-Tx for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:47 -0400 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-468-gYOX21jMOyGsp2unctN_GA-1; Thu, 26 Aug 2021 08:32:33 -0400 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 B08A41966323; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCD76604CC; Thu, 26 Aug 2021 12:32:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id ADFAB11380BA; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981155; 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=TeXbrMH6GEOkczvD8QINt/Y6SSvMVYn4yrLCzZqfwos=; b=QJFRE3ZZJVWAyHNdwBxXM/8PkZM2u12lpcDEUehR/Jp9noGJ38euOyZLLJBHuXPWz+Y2QA F3Mrtd7J5WHws7nCzfZacp+18Mpt6lpZTBn0nCNKX3gX5IEEaKvKrnZO4hMQswGqoH52Y7 ppMXJK3i8l+6g6ahohCg/7s5tLDYr6w= X-MC-Unique: gYOX21jMOyGsp2unctN_GA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 07/11] qapi: replace if condition list with dict {'all': [...]} Date: Thu, 26 Aug 2021 14:32:21 +0200 Message-Id: <20210826123225.157891-8-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981878244100001 From: Marc-Andr=C3=A9 Lureau Replace the simple list sugar form with a recursive structure that will accept other operators in the following commits (all, any or not). Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-7-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Accidental code motion undone. Degenerate :forms: comment dropped. Helper _check_if() moved. Error messages tweaked. ui.json updated. Accidental changes to qapi-schema-test.json dropped.] Signed-off-by: Markus Armbruster --- qapi/ui.json | 6 +- scripts/qapi/common.py | 23 +++++-- scripts/qapi/expr.py | 64 +++++++++++-------- scripts/qapi/schema.py | 2 +- tests/qapi-schema/bad-if-all.err | 2 + tests/qapi-schema/bad-if-all.json | 3 + tests/qapi-schema/bad-if-all.out | 0 tests/qapi-schema/bad-if-empty-list.json | 2 +- tests/qapi-schema/bad-if-key.err | 3 + tests/qapi-schema/bad-if-key.json | 3 + tests/qapi-schema/bad-if-key.out | 0 tests/qapi-schema/bad-if-keys.err | 2 + tests/qapi-schema/bad-if-keys.json | 3 + tests/qapi-schema/bad-if-keys.out | 0 tests/qapi-schema/bad-if-list.json | 2 +- tests/qapi-schema/bad-if.err | 2 +- tests/qapi-schema/bad-if.json | 2 +- tests/qapi-schema/doc-good.json | 3 +- tests/qapi-schema/doc-good.out | 13 ++-- tests/qapi-schema/doc-good.txt | 6 ++ tests/qapi-schema/enum-if-invalid.err | 3 +- tests/qapi-schema/features-if-invalid.err | 2 +- tests/qapi-schema/meson.build | 3 + tests/qapi-schema/qapi-schema-test.json | 20 +++--- tests/qapi-schema/qapi-schema-test.out | 58 ++++++++--------- .../qapi-schema/struct-member-if-invalid.err | 2 +- .../qapi-schema/union-branch-if-invalid.json | 2 +- 27 files changed, 143 insertions(+), 88 deletions(-) create mode 100644 tests/qapi-schema/bad-if-all.err create mode 100644 tests/qapi-schema/bad-if-all.json create mode 100644 tests/qapi-schema/bad-if-all.out create mode 100644 tests/qapi-schema/bad-if-key.err create mode 100644 tests/qapi-schema/bad-if-key.json create mode 100644 tests/qapi-schema/bad-if-key.out create mode 100644 tests/qapi-schema/bad-if-keys.err create mode 100644 tests/qapi-schema/bad-if-keys.json create mode 100644 tests/qapi-schema/bad-if-keys.out diff --git a/qapi/ui.json b/qapi/ui.json index fd9677d48e..aed2bec4ab 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1136,7 +1136,8 @@ { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' }, { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' }, { 'name': 'egl-headless', - 'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' }, + 'if': { 'all': [ 'defined(CONFIG_OPENGL)', + 'defined(CONFIG_GBM)' ] } }, { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' }, { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' }, { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] } @@ -1167,7 +1168,8 @@ 'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' }, 'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' = }, 'egl-headless': { 'type': 'DisplayEGLHeadless', - 'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GB= M)' } + 'if': { 'all': [ 'defined(CONFIG_OPENGL)', + 'defined(CONFIG_GBM)' ] } } } } =20 diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index ddc54e4368..3d7272a702 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -13,7 +13,8 @@ =20 import re from typing import ( - List, + Any, + Dict, Match, Optional, Union, @@ -199,17 +200,29 @@ def guardend(name: str) -> str: name=3Dc_fname(name).upper()) =20 =20 -def cgen_ifcond(ifcond: Union[str, List[str]]) -> str: +def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str: if not ifcond: return '' - return '(' + ') && ('.join(ifcond) + ')' + if isinstance(ifcond, str): + return ifcond + + oper, operands =3D next(iter(ifcond.items())) + oper =3D {'all': '&&'}[oper] + operands =3D [cgen_ifcond(o) for o in operands] + return '(' + (') ' + oper + ' (').join(operands) + ')' =20 =20 -def docgen_ifcond(ifcond: Union[str, List[str]]) -> str: +def docgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str: # TODO Doc generated for conditions needs polish if not ifcond: return '' - return ' and '.join(ifcond) + if isinstance(ifcond, str): + return ifcond + + oper, operands =3D next(iter(ifcond.items())) + oper =3D {'all': ' and '}[oper] + operands =3D [docgen_ifcond(o) for o in operands] + return '(' + oper.join(operands) + ')' =20 =20 def gen_if(cond: str) -> str: diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index cf98923fa6..d7a34655a7 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -259,14 +259,9 @@ def check_flags(expr: _JSONObject, info: QAPISourceInf= o) -> None: =20 def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None: """ - Normalize and validate the ``if`` member of an object. + Validate the ``if`` member of an object. =20 - The ``if`` member may be either a ``str`` or a ``List[str]``. - A ``str`` value will be normalized to ``List[str]``. - - :forms: - :sugared: ``Union[str, List[str]]`` - :canonical: ``List[str]`` + The ``if`` member may be either a ``str`` or a dict. =20 :param expr: The expression containing the ``if`` member to validate. :param info: QAPI schema source file information. @@ -275,31 +270,46 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo,= source: str) -> None: :raise QAPISemError: When the "if" member fails validation, or when there are no non-empty conditions. - :return: None, ``expr`` is normalized in-place as needed. + :return: None """ + + def _check_if(cond: Union[str, object]) -> None: + if isinstance(cond, str): + if not cond.strip(): + raise QAPISemError( + info, + "'if' condition '%s' of %s makes no sense" + % (cond, source)) + return + + if not isinstance(cond, dict): + raise QAPISemError( + info, + "'if' condition of %s must be a string or an object" % sou= rce) + if len(cond) !=3D 1: + raise QAPISemError( + info, + "'if' condition dict of %s must have one key: " + "'all'" % source) + check_keys(cond, info, "'if' condition", [], + ["all"]) + + oper, operands =3D next(iter(cond.items())) + if not operands: + raise QAPISemError( + info, "'if' condition [] of %s is useless" % source) + + if oper in ("all") and not isinstance(operands, list): + raise QAPISemError( + info, "'%s' condition of %s must be an array" % (oper, sou= rce)) + for operand in operands: + _check_if(operand) + ifcond =3D expr.get('if') if ifcond is None: return =20 - if isinstance(ifcond, list): - if not ifcond: - raise QAPISemError( - info, "'if' condition [] of %s is useless" % source) - else: - # Normalize to a list - ifcond =3D expr['if'] =3D [ifcond] - - for elt in ifcond: - if not isinstance(elt, str): - raise QAPISemError( - info, - "'if' condition of %s must be a string or a list of string= s" - % source) - if not elt.strip(): - raise QAPISemError( - info, - "'if' condition '%s' of %s makes no sense" - % (elt, source)) + _check_if(ifcond) =20 =20 def normalize_members(members: object) -> None: diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a9345af7b7..229d24fce9 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -32,7 +32,7 @@ =20 class QAPISchemaIfCond: def __init__(self, ifcond=3DNone): - self.ifcond =3D ifcond or [] + self.ifcond =3D ifcond or {} =20 def cgen(self): return cgen_ifcond(self.ifcond) diff --git a/tests/qapi-schema/bad-if-all.err b/tests/qapi-schema/bad-if-al= l.err new file mode 100644 index 0000000000..a04f6e7043 --- /dev/null +++ b/tests/qapi-schema/bad-if-all.err @@ -0,0 +1,2 @@ +bad-if-all.json: In struct 'TestIfStruct': +bad-if-all.json:2: 'all' condition of struct must be an array diff --git a/tests/qapi-schema/bad-if-all.json b/tests/qapi-schema/bad-if-a= ll.json new file mode 100644 index 0000000000..44837d3981 --- /dev/null +++ b/tests/qapi-schema/bad-if-all.json @@ -0,0 +1,3 @@ +# check 'if all' is not a list +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'all': 'ALL' } } diff --git a/tests/qapi-schema/bad-if-all.out b/tests/qapi-schema/bad-if-al= l.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/bad-if-empty-list.json b/tests/qapi-schema/b= ad-if-empty-list.json index 94f2eb8670..b62b5671df 100644 --- a/tests/qapi-schema/bad-if-empty-list.json +++ b/tests/qapi-schema/bad-if-empty-list.json @@ -1,3 +1,3 @@ # check empty 'if' list { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, - 'if': [] } + 'if': { 'all': [] } } diff --git a/tests/qapi-schema/bad-if-key.err b/tests/qapi-schema/bad-if-ke= y.err new file mode 100644 index 0000000000..725d5abae5 --- /dev/null +++ b/tests/qapi-schema/bad-if-key.err @@ -0,0 +1,3 @@ +bad-if-key.json: In struct 'TestIfStruct': +bad-if-key.json:2: 'if' condition has unknown key 'value' +Valid keys are 'all'. diff --git a/tests/qapi-schema/bad-if-key.json b/tests/qapi-schema/bad-if-k= ey.json new file mode 100644 index 0000000000..64c74c13f2 --- /dev/null +++ b/tests/qapi-schema/bad-if-key.json @@ -0,0 +1,3 @@ +# check unknown 'if' dict key +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'value': 'defined(TEST_IF_STRUCT)' } } diff --git a/tests/qapi-schema/bad-if-key.out b/tests/qapi-schema/bad-if-ke= y.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/bad-if-keys.err b/tests/qapi-schema/bad-if-k= eys.err new file mode 100644 index 0000000000..b072db9a6f --- /dev/null +++ b/tests/qapi-schema/bad-if-keys.err @@ -0,0 +1,2 @@ +bad-if-keys.json: In struct 'TestIfStruct': +bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all' diff --git a/tests/qapi-schema/bad-if-keys.json b/tests/qapi-schema/bad-if-= keys.json new file mode 100644 index 0000000000..9e2f39ae21 --- /dev/null +++ b/tests/qapi-schema/bad-if-keys.json @@ -0,0 +1,3 @@ +# check multiple 'if' keys +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'any': ['ANY'], 'all': ['ALL'] } } diff --git a/tests/qapi-schema/bad-if-keys.out b/tests/qapi-schema/bad-if-k= eys.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/bad-if-list.json b/tests/qapi-schema/bad-if-= list.json index ea3d95bb6b..1fefef16a7 100644 --- a/tests/qapi-schema/bad-if-list.json +++ b/tests/qapi-schema/bad-if-list.json @@ -1,3 +1,3 @@ # check invalid 'if' content { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, - 'if': ['foo', ' '] } + 'if': { 'all': ['foo', ' '] } } diff --git a/tests/qapi-schema/bad-if.err b/tests/qapi-schema/bad-if.err index f83dee65da..ec373b213f 100644 --- a/tests/qapi-schema/bad-if.err +++ b/tests/qapi-schema/bad-if.err @@ -1,2 +1,2 @@ bad-if.json: In struct 'TestIfStruct': -bad-if.json:2: 'if' condition of struct must be a string or a list of stri= ngs +bad-if.json:2: 'if' condition of struct must be a string or an object diff --git a/tests/qapi-schema/bad-if.json b/tests/qapi-schema/bad-if.json index 3edd1a0bf2..fdc0c87bb3 100644 --- a/tests/qapi-schema/bad-if.json +++ b/tests/qapi-schema/bad-if.json @@ -1,3 +1,3 @@ # check invalid 'if' type { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, - 'if': { 'value': 'defined(TEST_IF_STRUCT)' } } + 'if': ['defined(TEST_IF_STRUCT)'] } diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 423ea23e07..25b1053e8a 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -70,7 +70,8 @@ # @base1: # the first member ## -{ 'struct': 'Base', 'data': { 'base1': 'Enum' } } +{ 'struct': 'Base', 'data': { 'base1': 'Enum' }, + 'if': { 'all': ['IFALL1', 'IFALL2'] } } =20 ## # @Variant1: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 8f54ceff2e..689d084f3a 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -12,15 +12,16 @@ enum QType module doc-good.json enum Enum member one - if ['defined(IFONE)'] + if defined(IFONE) member two - if ['defined(IFCOND)'] + if defined(IFCOND) feature enum-feat object Base member base1: Enum optional=3DFalse + if OrderedDict([('all', ['IFALL1', 'IFALL2'])]) object Variant1 member var1: str optional=3DFalse - if ['defined(IFSTR)'] + if defined(IFSTR) feature member-feat feature variant1-feat object Variant2 @@ -29,7 +30,7 @@ object Object tag base1 case one: Variant1 case two: Variant2 - if ['IFTWO'] + if IFTWO feature union-feat1 object q_obj_Variant1-wrapper member data: Variant1 optional=3DFalse @@ -38,13 +39,13 @@ object q_obj_Variant2-wrapper enum SugaredUnionKind member one member two - if ['IFTWO'] + if IFTWO object SugaredUnion member type: SugaredUnionKind optional=3DFalse tag type case one: q_obj_Variant1-wrapper case two: q_obj_Variant2-wrapper - if ['IFTWO'] + if IFTWO feature union-feat2 alternate Alternate tag type diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 726727af74..4490108cb7 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -76,6 +76,12 @@ Members the first member =20 =20 +If +~~ + +"(IFALL1 and IFALL2)" + + "Variant1" (Object) ------------------- =20 diff --git a/tests/qapi-schema/enum-if-invalid.err b/tests/qapi-schema/enum= -if-invalid.err index 0556dc967b..df305cd79f 100644 --- a/tests/qapi-schema/enum-if-invalid.err +++ b/tests/qapi-schema/enum-if-invalid.err @@ -1,2 +1,3 @@ enum-if-invalid.json: In enum 'TestIfEnum': -enum-if-invalid.json:2: 'if' condition of 'data' member 'bar' must be a st= ring or a list of strings +enum-if-invalid.json:2: 'if' condition has unknown key 'val' +Valid keys are 'all'. diff --git a/tests/qapi-schema/features-if-invalid.err b/tests/qapi-schema/= features-if-invalid.err index f63b89535e..0ce7b6fcdf 100644 --- a/tests/qapi-schema/features-if-invalid.err +++ b/tests/qapi-schema/features-if-invalid.err @@ -1,2 +1,2 @@ features-if-invalid.json: In struct 'Stru': -features-if-invalid.json:2: 'if' condition of 'features' member 'f' must b= e a string or a list of strings +features-if-invalid.json:2: 'if' condition of 'features' member 'f' must b= e a string or an object diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index b8de58116a..4697c070bc 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -37,8 +37,11 @@ schemas =3D [ 'bad-data.json', 'bad-ident.json', 'bad-if.json', + 'bad-if-all.json', 'bad-if-empty.json', 'bad-if-empty-list.json', + 'bad-if-key.json', + 'bad-if-keys.json', 'bad-if-list.json', 'bad-type-bool.json', 'bad-type-dict.json', diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 84b9d41f15..e85a71c0f7 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -232,7 +232,7 @@ { 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct', 'bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, - 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } + 'if': { 'all': ['defined(TEST_IF_UNION)', 'defined(TEST_IF_STRUCT)'] } } =20 { 'command': 'test-if-union-cmd', 'data': { 'union-cmd-arg': 'TestIfUnion' }, @@ -241,25 +241,25 @@ { 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', 'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} }, - 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } + 'if': { 'all': ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRUCT)'] } } =20 { 'command': 'test-if-alternate-cmd', 'data': { 'alt-cmd-arg': 'TestIfAlternate' }, - 'if': 'defined(TEST_IF_ALT)' } + 'if': { 'all': ['defined(TEST_IF_ALT)'] } } =20 { 'command': 'test-if-cmd', 'data': { 'foo': 'TestIfStruct', 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } }, 'returns': 'UserDefThree', - 'if': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] } + 'if': { 'all': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] } } =20 { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } =20 { 'event': 'TEST_IF_EVENT', 'data': { 'foo': 'TestIfStruct', 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, - 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } + 'if': { 'all': ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRUCT)'] } } =20 # test 'features' =20 @@ -288,8 +288,9 @@ { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} = ] } { 'struct': 'CondFeatureStruct3', 'data': { 'foo': 'int' }, - 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', - 'defined(TEST_IF_COND_2)'] }= ] } + 'features': [ { 'name': 'feature1', + 'if': { 'all': [ 'defined(TEST_IF_COND_1)', + 'defined(TEST_IF_COND_2)'] } } ] } =20 { 'enum': 'FeatureEnum1', 'data': [ 'eins', 'zwei', 'drei' ], @@ -328,8 +329,9 @@ 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} = ] } { 'command': 'test-command-cond-features3', - 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', - 'defined(TEST_IF_COND_2)'] }= ] } + 'features': [ { 'name': 'feature1', + 'if': { 'all': [ 'defined(TEST_IF_COND_1)', + 'defined(TEST_IF_COND_2)'] } } ] } =20 { 'event': 'TEST_EVENT_FEATURES0', 'data': 'FeatureStruct1' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e0b8a5f0b6..e74756cfd8 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -298,65 +298,65 @@ command __org.qemu_x-command q_obj___org.qemu_x-comma= nd-arg -> __org.qemu_x-Unio object TestIfStruct member foo: int optional=3DFalse member bar: int optional=3DFalse - if ['defined(TEST_IF_STRUCT_BAR)'] - if ['defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_STRUCT_BAR) + if defined(TEST_IF_STRUCT) enum TestIfEnum member foo member bar - if ['defined(TEST_IF_ENUM_BAR)'] - if ['defined(TEST_IF_ENUM)'] + if defined(TEST_IF_ENUM_BAR) + if defined(TEST_IF_ENUM) object q_obj_TestStruct-wrapper member data: TestStruct optional=3DFalse enum TestIfUnionKind member foo member bar - if ['defined(TEST_IF_UNION_BAR)'] - if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_UNION_BAR) + if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_ST= RUCT)'])]) object TestIfUnion member type: TestIfUnionKind optional=3DFalse tag type case foo: q_obj_TestStruct-wrapper case bar: q_obj_str-wrapper - if ['defined(TEST_IF_UNION_BAR)'] - if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_UNION_BAR) + if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_ST= RUCT)'])]) object q_obj_test-if-union-cmd-arg member union-cmd-arg: TestIfUnion optional=3DFalse - if ['defined(TEST_IF_UNION)'] + if defined(TEST_IF_UNION) command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if ['defined(TEST_IF_UNION)'] + if defined(TEST_IF_UNION) alternate TestIfAlternate tag type case foo: int case bar: TestStruct - if ['defined(TEST_IF_ALT_BAR)'] - if ['defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_ALT_BAR) + if OrderedDict([('all', ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRU= CT)'])]) object q_obj_test-if-alternate-cmd-arg member alt-cmd-arg: TestIfAlternate optional=3DFalse - if ['defined(TEST_IF_ALT)'] + if OrderedDict([('all', ['defined(TEST_IF_ALT)'])]) command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if ['defined(TEST_IF_ALT)'] + if OrderedDict([('all', ['defined(TEST_IF_ALT)'])]) object q_obj_test-if-cmd-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse - if ['defined(TEST_IF_CMD_BAR)'] - if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_CMD_BAR) + if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRU= CT)'])]) command test-if-cmd q_obj_test-if-cmd-arg -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] + if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRU= CT)'])]) command test-cmd-return-def-three None -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse array TestIfEnumList TestIfEnum - if ['defined(TEST_IF_ENUM)'] + if defined(TEST_IF_ENUM) object q_obj_TEST_IF_EVENT-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnumList optional=3DFalse - if ['defined(TEST_IF_EVT_BAR)'] - if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] + if defined(TEST_IF_EVT_BAR) + if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRU= CT)'])]) event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg boxed=3DFalse - if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] + if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRU= CT)'])]) object FeatureStruct0 member foo: int optional=3DFalse object FeatureStruct1 @@ -379,17 +379,17 @@ object FeatureStruct4 object CondFeatureStruct1 member foo: int optional=3DFalse feature feature1 - if ['defined(TEST_IF_FEATURE_1)'] + if defined(TEST_IF_FEATURE_1) object CondFeatureStruct2 member foo: int optional=3DFalse feature feature1 - if ['defined(TEST_IF_FEATURE_1)'] + if defined(TEST_IF_FEATURE_1) feature feature2 - if ['defined(TEST_IF_FEATURE_2)'] + if defined(TEST_IF_FEATURE_2) object CondFeatureStruct3 member foo: int optional=3DFalse feature feature1 - if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] + if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) enum FeatureEnum1 member eins member zwei @@ -429,17 +429,17 @@ command test-command-features3 None -> None command test-command-cond-features1 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 - if ['defined(TEST_IF_FEATURE_1)'] + if defined(TEST_IF_FEATURE_1) command test-command-cond-features2 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 - if ['defined(TEST_IF_FEATURE_1)'] + if defined(TEST_IF_FEATURE_1) feature feature2 - if ['defined(TEST_IF_FEATURE_2)'] + if defined(TEST_IF_FEATURE_2) 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)'] + if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) event TEST_EVENT_FEATURES0 FeatureStruct1 boxed=3DFalse event TEST_EVENT_FEATURES1 None diff --git a/tests/qapi-schema/struct-member-if-invalid.err b/tests/qapi-sc= hema/struct-member-if-invalid.err index 42e7fdae3c..5ee08afa41 100644 --- a/tests/qapi-schema/struct-member-if-invalid.err +++ b/tests/qapi-schema/struct-member-if-invalid.err @@ -1,2 +1,2 @@ struct-member-if-invalid.json: In struct 'Stru': -struct-member-if-invalid.json:2: 'if' condition of 'data' member 'member' = must be a string or a list of strings +struct-member-if-invalid.json:2: 'if' condition of 'data' member 'member' = must be a string or an object diff --git a/tests/qapi-schema/union-branch-if-invalid.json b/tests/qapi-sc= hema/union-branch-if-invalid.json index 46d4239af6..c41633856f 100644 --- a/tests/qapi-schema/union-branch-if-invalid.json +++ b/tests/qapi-schema/union-branch-if-invalid.json @@ -3,4 +3,4 @@ { 'struct': 'Stru', 'data': { 'member': 'str' } } { 'union': 'Uni', 'base': { 'tag': 'Branches' }, 'discriminator': 'tag', - 'data': { 'branch1': { 'type': 'Stru', 'if': [''] } } } + 'data': { 'branch1': { 'type': 'Stru', 'if': { 'all': [''] } } } } --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981750; cv=none; d=zohomail.com; s=zohoarc; b=gQp03poslYIuaqavj1pdLf6ArQMndnv6T3fT8SSVeqvbFFBTj+SwAiPsIHKkUVCXNx9cF+p8Qy/4FJ/G1ywcyDgVOfw2mU4JDVEqNl45F8btgVpwZ2GYVStWzKm1Dha+jyp0z4r81Dtfy++te6IH8AXgJGD10R18cW68q1cplOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981750; 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=Y+leUpHX+6A8WbUTKT4sOwbpktub1GqAlJx4luuoj6Q=; b=ks3yjUwEwHkPpmukpS55/66JXTaZAhW/xJr/WreKoJkCUZWlIAG6KfxuWjBxFYuQ8hY1xZs1pg4Ydx9PVPNHv2jnpTRpVD3gOwayLkxmz/QEnKadRYv9s7ryY5DItqD5Z/QF/URJl2RIQqsUAq/isM2UlpnsBzuGmt/WTB8XlEY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981750245598.5423101761727; Thu, 26 Aug 2021 05:42:30 -0700 (PDT) Received: from localhost ([::1]:36364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEiD-0006zz-0M for importer@patchew.org; Thu, 26 Aug 2021 08:42:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYv-0004CO-G9 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYh-0008Bb-VP for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:53 -0400 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-548-UI45yv0PPvCGnMoc1Trb8A-1; Thu, 26 Aug 2021 08:32:32 -0400 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 D25651966320; Thu, 26 Aug 2021 12:32:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD0756A8E7; Thu, 26 Aug 2021 12:32:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B168111380BC; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981154; 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=Y+leUpHX+6A8WbUTKT4sOwbpktub1GqAlJx4luuoj6Q=; b=ZmeSJfr61IohtAs2fyg/oAi5TVA9Vm4Ycf55s64IQkRjMACBLibO7fZMFLznwezxyw5Hdo OgOYxSI8G5rPP82VazKTTHWGBKiO6p/6wgnFwllwv0XHDS3xHQrlUniSbduIKHahASHbNJ EJE2wF8ycgfRwXqFl8+BxmN+rI9AEn0= X-MC-Unique: UI45yv0PPvCGnMoc1Trb8A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 08/11] qapi: add 'any' condition Date: Thu, 26 Aug 2021 14:32:22 +0200 Message-Id: <20210826123225.157891-9-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, WEIRD_QUOTING=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981750912100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-8-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- tests/unit/test-qmp-cmds.c | 1 + scripts/qapi/common.py | 4 ++-- scripts/qapi/expr.py | 6 +++--- tests/qapi-schema/bad-if-key.err | 2 +- tests/qapi-schema/bad-if-keys.err | 2 +- tests/qapi-schema/doc-good.json | 4 +++- tests/qapi-schema/doc-good.out | 2 +- tests/qapi-schema/doc-good.txt | 3 ++- tests/qapi-schema/enum-if-invalid.err | 2 +- tests/qapi-schema/qapi-schema-test.json | 8 +++++++- tests/qapi-schema/qapi-schema-test.out | 5 +++++ 11 files changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 1b0b7d99df..83efa39720 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -51,6 +51,7 @@ FeatureStruct1 *qmp_test_features0(bool has_fs0, FeatureS= truct0 *fs0, bool has_cfs1, CondFeatureStruct1 *cfs1, bool has_cfs2, CondFeatureStruct2 *cfs2, bool has_cfs3, CondFeatureStruct3 *cfs3, + bool has_cfs4, CondFeatureStruct4 *cfs4, Error **errp) { return g_new0(FeatureStruct1, 1); diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 3d7272a702..63a2e502fb 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -207,7 +207,7 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> = str: return ifcond =20 oper, operands =3D next(iter(ifcond.items())) - oper =3D {'all': '&&'}[oper] + oper =3D {'all': '&&', 'any': '||'}[oper] operands =3D [cgen_ifcond(o) for o in operands] return '(' + (') ' + oper + ' (').join(operands) + ')' =20 @@ -220,7 +220,7 @@ def docgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -= > str: return ifcond =20 oper, operands =3D next(iter(ifcond.items())) - oper =3D {'all': ' and '}[oper] + oper =3D {'all': ' and ', 'any': ' or '}[oper] operands =3D [docgen_ifcond(o) for o in operands] return '(' + oper.join(operands) + ')' =20 diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index d7a34655a7..f3ce10fb3e 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -290,16 +290,16 @@ def _check_if(cond: Union[str, object]) -> None: raise QAPISemError( info, "'if' condition dict of %s must have one key: " - "'all'" % source) + "'all' or 'any'" % source) check_keys(cond, info, "'if' condition", [], - ["all"]) + ["all", "any"]) =20 oper, operands =3D next(iter(cond.items())) if not operands: raise QAPISemError( info, "'if' condition [] of %s is useless" % source) =20 - if oper in ("all") and not isinstance(operands, list): + if oper in ("all", "any") and not isinstance(operands, list): raise QAPISemError( info, "'%s' condition of %s must be an array" % (oper, sou= rce)) for operand in operands: diff --git a/tests/qapi-schema/bad-if-key.err b/tests/qapi-schema/bad-if-ke= y.err index 725d5abae5..7236f46e7a 100644 --- a/tests/qapi-schema/bad-if-key.err +++ b/tests/qapi-schema/bad-if-key.err @@ -1,3 +1,3 @@ bad-if-key.json: In struct 'TestIfStruct': bad-if-key.json:2: 'if' condition has unknown key 'value' -Valid keys are 'all'. +Valid keys are 'all', 'any'. diff --git a/tests/qapi-schema/bad-if-keys.err b/tests/qapi-schema/bad-if-k= eys.err index b072db9a6f..db6d019d77 100644 --- a/tests/qapi-schema/bad-if-keys.err +++ b/tests/qapi-schema/bad-if-keys.err @@ -1,2 +1,2 @@ bad-if-keys.json: In struct 'TestIfStruct': -bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all' +bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all'= or 'any' diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 25b1053e8a..e253d89ee0 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -103,7 +103,9 @@ 'features': [ 'union-feat1' ], 'base': 'Base', 'discriminator': 'base1', - 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' = } } } + 'data': { 'one': 'Variant1', + 'two': { 'type': 'Variant2', + 'if': { 'any': ['IFONE', 'IFTWO'] } } } } =20 ## # @SugaredUnion: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 689d084f3a..c44c346ec8 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -30,7 +30,7 @@ object Object tag base1 case one: Variant1 case two: Variant2 - if IFTWO + if OrderedDict([('any', ['IFONE', 'IFTWO'])]) feature union-feat1 object q_obj_Variant1-wrapper member data: Variant1 optional=3DFalse diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 4490108cb7..251e9b746c 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -120,7 +120,8 @@ Members =20 The members of "Base" The members of "Variant1" when "base1" is ""one"" -The members of "Variant2" when "base1" is ""two"" (**If: **"IFTWO") +The members of "Variant2" when "base1" is ""two"" (**If: **"(IFONE or +IFTWO)") =20 Features ~~~~~~~~ diff --git a/tests/qapi-schema/enum-if-invalid.err b/tests/qapi-schema/enum= -if-invalid.err index df305cd79f..b96d94c48a 100644 --- a/tests/qapi-schema/enum-if-invalid.err +++ b/tests/qapi-schema/enum-if-invalid.err @@ -1,3 +1,3 @@ enum-if-invalid.json: In enum 'TestIfEnum': enum-if-invalid.json:2: 'if' condition has unknown key 'val' -Valid keys are 'all'. +Valid keys are 'all', 'any'. diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index e85a71c0f7..7737b32de8 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -291,6 +291,11 @@ 'features': [ { 'name': 'feature1', 'if': { 'all': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] } } ] } +{ 'struct': 'CondFeatureStruct4', + 'data': { 'foo': 'int' }, + 'features': [ { 'name': 'feature1', + 'if': {'any': ['defined(TEST_IF_COND_1)', + 'defined(TEST_IF_COND_2)'] } } ] } =20 { 'enum': 'FeatureEnum1', 'data': [ 'eins', 'zwei', 'drei' ], @@ -314,7 +319,8 @@ '*fs4': 'FeatureStruct4', '*cfs1': 'CondFeatureStruct1', '*cfs2': 'CondFeatureStruct2', - '*cfs3': 'CondFeatureStruct3' }, + '*cfs3': 'CondFeatureStruct3', + '*cfs4': 'CondFeatureStruct4' }, 'returns': 'FeatureStruct1', 'features': [] } =20 diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e74756cfd8..2f067d57af 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -390,6 +390,10 @@ object CondFeatureStruct3 member foo: int optional=3DFalse feature feature1 if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) +object CondFeatureStruct4 + member foo: int optional=3DFalse + feature feature1 + if OrderedDict([('any', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) enum FeatureEnum1 member eins member zwei @@ -417,6 +421,7 @@ object q_obj_test-features0-arg member cfs1: CondFeatureStruct1 optional=3DTrue member cfs2: CondFeatureStruct2 optional=3DTrue member cfs3: CondFeatureStruct3 optional=3DTrue + member cfs4: CondFeatureStruct4 optional=3DTrue command test-features0 q_obj_test-features0-arg -> FeatureStruct1 gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command test-command-features1 None -> None --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 Delivered-To: importer@patchew.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16299815372091009.8645395624492; Thu, 26 Aug 2021 05:38:57 -0700 (PDT) Received: from localhost ([::1]:58720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEem-00030h-6d for importer@patchew.org; Thu, 26 Aug 2021 08:38:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYm-0004Ai-9S for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYh-0008Bz-Rp for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:44 -0400 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-562-0kIu1FnBOzCQvwALsw3vHA-1; Thu, 26 Aug 2021 08:32:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A57C81008062; Thu, 26 Aug 2021 12:32:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88E1D5F724; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B4DB011380C3; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981157; 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=Rn2CN1rw2QVgV2voQEWpCgiUFC18pxVmFIWB9duZW0w=; b=HSJIxTH0xy3NTNP79WlOQkpO3wd9hhq3OqSNthf793sJ1rfKJGUybH8XrBzjwHiEq2K1mC 2qtqkbTVBQ5QynKZ73PlgvOFNnCzxlY/GVblnqJbVyXdBSbs+DTLL27vmrWmEau9gYonGx raen5a83/NMGcGolSjPbQUhtjpYADr8= X-MC-Unique: 0kIu1FnBOzCQvwALsw3vHA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 09/11] qapi: Use 'if': { 'any': ... } where appropriate Date: Thu, 26 Aug 2021 14:32:23 +0200 Message-Id: <20210826123225.157891-10-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629981537934100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi Tested-by: John Snow Reviewed-by: Markus Armbruster Message-Id: <20210804083105.97531-9-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster --- qapi/machine-target.json | 20 ++++++++++++++++---- qapi/misc-target.json | 12 +++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index e7811654b7..9b56b81bea 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -213,7 +213,9 @@ ## { 'struct': 'CpuModelExpansionInfo', 'data': { 'model': 'CpuModelInfo' }, - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_A= RM)' } + 'if': { 'any': [ 'defined(TARGET_S390X)', + 'defined(TARGET_I386)', + 'defined(TARGET_ARM)'] } } =20 ## # @query-cpu-model-expansion: @@ -252,7 +254,9 @@ 'data': { 'type': 'CpuModelExpansionType', 'model': 'CpuModelInfo' }, 'returns': 'CpuModelExpansionInfo', - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_A= RM)' } + 'if': { 'any': [ 'defined(TARGET_S390X)', + 'defined(TARGET_I386)', + 'defined(TARGET_ARM)' ] } } =20 ## # @CpuDefinitionInfo: @@ -316,7 +320,11 @@ 'typename': 'str', '*alias-of' : 'str', 'deprecated' : 'bool' }, - 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386= ) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } + 'if': { 'any': [ 'defined(TARGET_PPC)', + 'defined(TARGET_ARM)', + 'defined(TARGET_I386)', + 'defined(TARGET_S390X)', + 'defined(TARGET_MIPS)' ] } } =20 ## # @query-cpu-definitions: @@ -328,4 +336,8 @@ # Since: 1.2 ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], - 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386= ) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } + 'if': { 'any': [ 'defined(TARGET_PPC)', + 'defined(TARGET_ARM)', + 'defined(TARGET_I386)', + 'defined(TARGET_S390X)', + 'defined(TARGET_MIPS)' ] } } diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 5573dcf8f0..9e2ea4a04a 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -23,7 +23,17 @@ ## { 'event': 'RTC_CHANGE', 'data': { 'offset': 'int' }, - 'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) || defined(TARGET_HP= PA) || defined(TARGET_I386) || defined(TARGET_MIPS) || defined(TARGET_MIPS6= 4) || defined(TARGET_PPC) || defined(TARGET_PPC64) || defined(TARGET_S390X)= || defined(TARGET_SH4) || defined(TARGET_SPARC)' } + 'if': { 'any': [ 'defined(TARGET_ALPHA)', + 'defined(TARGET_ARM)', + 'defined(TARGET_HPPA)', + 'defined(TARGET_I386)', + 'defined(TARGET_MIPS)', + 'defined(TARGET_MIPS64)', + 'defined(TARGET_PPC)', + 'defined(TARGET_PPC64)', + 'defined(TARGET_S390X)', + 'defined(TARGET_SH4)', + 'defined(TARGET_SPARC)' ] } } =20 ## # @rtc-reset-reinjection: --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629981362; cv=none; d=zohomail.com; s=zohoarc; b=fTKoOJL2B9NhZQTqO3DkOcKV5aPe+G3cNhHTxOoEVvfyzRBKVvIIMF53cuXdE3H3sIU7FKyFfXqDJwQrkdwF5Mn8Kt9crCiggNz2tn1bjdlwLehTTvMUq4OFOgmazvjkHLNTHrCwjgdQXUlImV2YpDW4XhBjaB2Pr/o98rO6KPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629981362; 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=6GKi0XJTbgsMLnRtNs0aY+1QpIBEi8PJj0jzhMrCFlw=; b=Ltg3DN2lAyXr48S/ZNEFk2OfW1sCpq1CUYpfcnUmAUk4cmgWiqLfJnvPa7PqEErmoi0zMOXD0StCAgqLxJTeEPpLTQLo2C5wS5ApNMlRb0JmpZ/p+5XUMBcn9plmGYncXiUH9U35fMN2nNK+GCjE3QnvD2vKsPb1eKNJ4hxwuQo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981362877285.744276661042; Thu, 26 Aug 2021 05:36:02 -0700 (PDT) Received: from localhost ([::1]:52400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEbx-00079o-Od for importer@patchew.org; Thu, 26 Aug 2021 08:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYq-0004At-0G for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYi-0008Bl-70 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:47 -0400 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-436-zMdo2WpyPtyBSnL469MTiw-1; Thu, 26 Aug 2021 08:32:33 -0400 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 D8F9A1008066; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8719860583; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B83C611380CC; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981155; 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=6GKi0XJTbgsMLnRtNs0aY+1QpIBEi8PJj0jzhMrCFlw=; b=R+BUxWp15712khXjJwsOJTxaCXj/EktpQ/mVzRCmVR0KnO6Hr25n4zxHKwy/Fuj2lEFPdC NZt3hLof/uNETQZnhg3h6LCJD5O4heObQzZDjYstfTOW7UEAfRza64+sKdU0GVrXM85kwC HJ77VXF6aad2aF75YptYLSnN093LE6Q= X-MC-Unique: zMdo2WpyPtyBSnL469MTiw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 10/11] qapi: add 'not' condition operation Date: Thu, 26 Aug 2021 14:32:24 +0200 Message-Id: <20210826123225.157891-11-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629981363308100001 From: Marc-Andr=C3=A9 Lureau For the sake of completeness, introduce the 'not' condition. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210804083105.97531-10-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Long line broken in tests/qapi-schema/qapi-schema-test.json] Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 4 ++++ scripts/qapi/expr.py | 7 +++++-- tests/qapi-schema/bad-if-key.err | 2 +- tests/qapi-schema/bad-if-keys.err | 2 +- tests/qapi-schema/doc-good.json | 3 ++- tests/qapi-schema/doc-good.out | 1 + tests/qapi-schema/doc-good.txt | 6 ++++++ tests/qapi-schema/enum-if-invalid.err | 2 +- tests/qapi-schema/qapi-schema-test.json | 3 ++- tests/qapi-schema/qapi-schema-test.out | 4 ++-- 10 files changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 63a2e502fb..3fb2fbe7d4 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -207,6 +207,8 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> = str: return ifcond =20 oper, operands =3D next(iter(ifcond.items())) + if oper =3D=3D 'not': + return '!' + cgen_ifcond(operands) oper =3D {'all': '&&', 'any': '||'}[oper] operands =3D [cgen_ifcond(o) for o in operands] return '(' + (') ' + oper + ' (').join(operands) + ')' @@ -220,6 +222,8 @@ def docgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -= > str: return ifcond =20 oper, operands =3D next(iter(ifcond.items())) + if oper =3D=3D 'not': + return '!' + docgen_ifcond(operands) oper =3D {'all': ' and ', 'any': ' or '}[oper] operands =3D [docgen_ifcond(o) for o in operands] return '(' + oper.join(operands) + ')' diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index f3ce10fb3e..120b31089f 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -290,15 +290,18 @@ def _check_if(cond: Union[str, object]) -> None: raise QAPISemError( info, "'if' condition dict of %s must have one key: " - "'all' or 'any'" % source) + "'all', 'any' or 'not'" % source) check_keys(cond, info, "'if' condition", [], - ["all", "any"]) + ["all", "any", "not"]) =20 oper, operands =3D next(iter(cond.items())) if not operands: raise QAPISemError( info, "'if' condition [] of %s is useless" % source) =20 + if oper =3D=3D "not": + _check_if(operands) + return if oper in ("all", "any") and not isinstance(operands, list): raise QAPISemError( info, "'%s' condition of %s must be an array" % (oper, sou= rce)) diff --git a/tests/qapi-schema/bad-if-key.err b/tests/qapi-schema/bad-if-ke= y.err index 7236f46e7a..a69dc9ee86 100644 --- a/tests/qapi-schema/bad-if-key.err +++ b/tests/qapi-schema/bad-if-key.err @@ -1,3 +1,3 @@ bad-if-key.json: In struct 'TestIfStruct': bad-if-key.json:2: 'if' condition has unknown key 'value' -Valid keys are 'all', 'any'. +Valid keys are 'all', 'any', 'not'. diff --git a/tests/qapi-schema/bad-if-keys.err b/tests/qapi-schema/bad-if-k= eys.err index db6d019d77..aceb31dc6d 100644 --- a/tests/qapi-schema/bad-if-keys.err +++ b/tests/qapi-schema/bad-if-keys.err @@ -1,2 +1,2 @@ bad-if-keys.json: In struct 'TestIfStruct': -bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all'= or 'any' +bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all'= , 'any' or 'not' diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index e253d89ee0..2a35c679a4 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -126,7 +126,8 @@ ## { 'alternate': 'Alternate', 'features': [ 'alt-feat' ], - 'data': { 'i': 'int', 'b': 'bool' } } + 'data': { 'i': 'int', 'b': 'bool' }, + 'if': { 'not': 'IFNOT' } } =20 ## # =3D=3D Another subsection diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index c44c346ec8..a8871e8f99 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -51,6 +51,7 @@ alternate Alternate tag type case i: int case b: bool + if OrderedDict([('not', 'IFNOT')]) feature alt-feat object q_obj_cmd-arg member arg1: int optional=3DFalse diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 251e9b746c..03c98c4182 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -171,6 +171,12 @@ Features a feature =20 =20 +If +~~ + +"!IFNOT" + + Another subsection =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tests/qapi-schema/enum-if-invalid.err b/tests/qapi-schema/enum= -if-invalid.err index b96d94c48a..3bb84075a9 100644 --- a/tests/qapi-schema/enum-if-invalid.err +++ b/tests/qapi-schema/enum-if-invalid.err @@ -1,3 +1,3 @@ enum-if-invalid.json: In enum 'TestIfEnum': enum-if-invalid.json:2: 'if' condition has unknown key 'val' -Valid keys are 'all', 'any'. +Valid keys are 'all', 'any', 'not'. diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 7737b32de8..a700f2531b 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -245,7 +245,8 @@ =20 { 'command': 'test-if-alternate-cmd', 'data': { 'alt-cmd-arg': 'TestIfAlternate' }, - 'if': { 'all': ['defined(TEST_IF_ALT)'] } } + 'if': { 'all': ['defined(TEST_IF_ALT)', + {'not': 'defined(TEST_IF_NOT_ALT)'}] } } =20 { 'command': 'test-if-cmd', 'data': { diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 2f067d57af..53e12f3534 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -333,10 +333,10 @@ alternate TestIfAlternate if OrderedDict([('all', ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRU= CT)'])]) object q_obj_test-if-alternate-cmd-arg member alt-cmd-arg: TestIfAlternate optional=3DFalse - if OrderedDict([('all', ['defined(TEST_IF_ALT)'])]) + if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', = 'defined(TEST_IF_NOT_ALT)')])])]) command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if OrderedDict([('all', ['defined(TEST_IF_ALT)'])]) + if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', = 'defined(TEST_IF_NOT_ALT)')])])]) object q_obj_test-if-cmd-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse --=20 2.31.1 From nobody Sun Apr 28 00:29:53 2024 Delivered-To: importer@patchew.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629981684045422.97300149877094; Thu, 26 Aug 2021 05:41:24 -0700 (PDT) Received: from localhost ([::1]:34888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJEh8-0005xF-MR for importer@patchew.org; Thu, 26 Aug 2021 08:41:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYp-0004Ar-NZ for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJEYi-0008CC-6e for qemu-devel@nongnu.org; Thu, 26 Aug 2021 08:32:47 -0400 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-193-8YKHwyhtMIqGK8jmXnWRvA-1; Thu, 26 Aug 2021 08:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21E766409B; Thu, 26 Aug 2021 12:32:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 882555C25D; Thu, 26 Aug 2021 12:32:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BC80311380CD; Thu, 26 Aug 2021 14:32:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629981158; 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=9NSvi7uA4IoYy57dO6RwHSxMVLxPvT1vtujniGurYz4=; b=NoVyY+ILq+YyeGSsPOUJZ6N6pPVIX5JRleR5AbLAtALE3W3xKsi+pYnholiUinvMjrlAiI soDP7PCYpNpGsjJSqH+jI72CNFjAH+E/PAvIQrxuujdQb6Lb6V0HmxcVYP973GZ54icI/P EnPSv3dXNgsbWjVnvKUiHRzylNhGGYo= X-MC-Unique: 8YKHwyhtMIqGK8jmXnWRvA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 11/11] qapi: make 'if' condition strings simple identifiers Date: Thu, 26 Aug 2021 14:32:25 +0200 Message-Id: <20210826123225.157891-12-armbru@redhat.com> In-Reply-To: <20210826123225.157891-1-armbru@redhat.com> References: <20210826123225.157891-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629981685420100001 From: Marc-Andr=C3=A9 Lureau Change the 'if' condition strings to be C-agnostic. It will accept '[A-Z][A-Z0-9_]*' identifiers. This allows to express configuration conditions in other languages (Rust or Python for ex) or other more suitable forms. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi Tested-by: John Snow Message-Id: <20210804083105.97531-11-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Rebased with semantic conflict in redefined-event.json] Signed-off-by: Markus Armbruster --- qapi/block-core.json | 34 +++++----- qapi/block-export.json | 6 +- qapi/char.json | 12 ++-- qapi/machine-target.json | 40 +++++------ qapi/migration.json | 10 +-- qapi/misc-target.json | 50 +++++++------- qapi/qom.json | 10 +-- qapi/sockets.json | 6 +- qapi/tpm.json | 18 ++--- qapi/ui.json | 68 +++++++++---------- qga/qapi-schema.json | 8 +-- scripts/qapi/common.py | 2 +- scripts/qapi/expr.py | 4 +- .../alternate-branch-if-invalid.err | 2 +- tests/qapi-schema/bad-if-empty.err | 2 +- tests/qapi-schema/bad-if-list.err | 2 +- tests/qapi-schema/bad-if.json | 2 +- tests/qapi-schema/doc-good.json | 6 +- tests/qapi-schema/doc-good.out | 6 +- tests/qapi-schema/doc-good.txt | 6 +- tests/qapi-schema/features-missing-name.json | 2 +- tests/qapi-schema/qapi-schema-test.json | 54 +++++++-------- tests/qapi-schema/qapi-schema-test.out | 60 ++++++++-------- tests/qapi-schema/redefined-event.json | 2 +- tests/qapi-schema/union-branch-if-invalid.err | 2 +- 25 files changed, 206 insertions(+), 208 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 675d8265eb..06674c25c9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -914,7 +914,7 @@ 'data': { 'file': 'BlockStatsSpecificFile', 'host_device': { 'type': 'BlockStatsSpecificFile', - 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, + 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'nvme': 'BlockStatsSpecificNvme' } } =20 ## @@ -2796,7 +2796,7 @@ ## { 'enum': 'BlockdevAioOptions', 'data': [ 'threads', 'native', - { 'name': 'io_uring', 'if': 'defined(CONFIG_LINUX_IO_URING)' }= ] } + { 'name': 'io_uring', 'if': 'CONFIG_LINUX_IO_URING' } ] } =20 ## # @BlockdevCacheOptions: @@ -2832,12 +2832,12 @@ 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ft= ps', 'gluster', - {'name': 'host_cdrom', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)'= }, - {'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)= ' }, + {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, + {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallel= s', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', - { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, + { 'name': 'replication', 'if': 'CONFIG_REPLICATION' }, 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } =20 ## @@ -2879,10 +2879,10 @@ '*locking': 'OnOffAuto', '*aio': 'BlockdevAioOptions', '*drop-cache': {'type': 'bool', - 'if': 'defined(CONFIG_LINUX)'}, + 'if': 'CONFIG_LINUX'}, '*x-check-cache-dropped': 'bool' }, 'features': [ { 'name': 'dynamic-auto-read-only', - 'if': 'defined(CONFIG_POSIX)' } ] } + 'if': 'CONFIG_POSIX' } ] } =20 ## # @BlockdevOptionsNull: @@ -3774,7 +3774,7 @@ # Since: 2.9 ## { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ], - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @BlockdevOptionsReplication: @@ -3793,7 +3793,7 @@ 'base': 'BlockdevOptionsGenericFormat', 'data': { 'mode': 'ReplicationMode', '*top-id': 'str' }, - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @NFSTransport: @@ -4108,9 +4108,9 @@ 'ftps': 'BlockdevOptionsCurlFtps', 'gluster': 'BlockdevOptionsGluster', 'host_cdrom': { 'type': 'BlockdevOptionsFile', - 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, + 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'host_device': { 'type': 'BlockdevOptionsFile', - 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, + 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'http': 'BlockdevOptionsCurlHttp', 'https': 'BlockdevOptionsCurlHttps', 'iscsi': 'BlockdevOptionsIscsi', @@ -4129,7 +4129,7 @@ 'raw': 'BlockdevOptionsRaw', 'rbd': 'BlockdevOptionsRbd', 'replication': { 'type': 'BlockdevOptionsReplication', - 'if': 'defined(CONFIG_REPLICATION)' }, + 'if': 'CONFIG_REPLICATION' }, 'ssh': 'BlockdevOptionsSsh', 'throttle': 'BlockdevOptionsThrottle', 'vdi': 'BlockdevOptionsGenericFormat', @@ -4307,8 +4307,8 @@ # @size: Size of the virtual disk in bytes # @preallocation: Preallocation mode for the new image (default: off; # allowed values: off, -# falloc (if defined CONFIG_POSIX_FALLOCATE), -# full (if defined CONFIG_POSIX)) +# falloc (if CONFIG_POSIX_FALLOCATE), +# full (if CONFIG_POSIX)) # @nocow: Turn off copy-on-write (valid only on btrfs; default: off) # @extent-size-hint: Extent size hint to add to the image file; 0 for not # adding an extent size hint (default: 1 MB, since 5.1) @@ -4331,8 +4331,8 @@ # @size: Size of the virtual disk in bytes # @preallocation: Preallocation mode for the new image (default: off; # allowed values: off, -# falloc (if defined CONFIG_GLUSTERFS_FALLOCATE), -# full (if defined CONFIG_GLUSTERFS_ZEROFILL)) +# falloc (if CONFIG_GLUSTERFS_FALLOCATE), +# full (if CONFIG_GLUSTERFS_ZEROFILL)) # # Since: 2.12 ## @@ -4432,7 +4432,7 @@ # Since: 5.1 ## { 'enum': 'Qcow2CompressionType', - 'data': [ 'zlib', { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } + 'data': [ 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] } =20 ## # @BlockdevCreateOptionsQcow2: diff --git a/qapi/block-export.json b/qapi/block-export.json index 0ed63442a8..c1b92ce1c1 100644 --- a/qapi/block-export.json +++ b/qapi/block-export.json @@ -168,7 +168,7 @@ 'data': { 'mountpoint': 'str', '*growable': 'bool', '*allow-other': 'FuseExportAllowOther' }, - 'if': 'defined(CONFIG_FUSE)' } + 'if': 'CONFIG_FUSE' } =20 ## # @NbdServerAddOptions: @@ -278,7 +278,7 @@ ## { 'enum': 'BlockExportType', 'data': [ 'nbd', 'vhost-user-blk', - { 'name': 'fuse', 'if': 'defined(CONFIG_FUSE)' } ] } + { 'name': 'fuse', 'if': 'CONFIG_FUSE' } ] } =20 ## # @BlockExportOptions: @@ -321,7 +321,7 @@ 'nbd': 'BlockExportOptionsNbd', 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk', 'fuse': { 'type': 'BlockExportOptionsFuse', - 'if': 'defined(CONFIG_FUSE)' } + 'if': 'CONFIG_FUSE' } } } =20 ## diff --git a/qapi/char.json b/qapi/char.json index adf2685f68..9b18ee3305 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -342,7 +342,7 @@ { 'struct': 'ChardevSpiceChannel', 'data': { 'type': 'str' }, 'base': 'ChardevCommon', - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @ChardevSpicePort: @@ -356,7 +356,7 @@ { 'struct': 'ChardevSpicePort', 'data': { 'fqdn': 'str' }, 'base': 'ChardevCommon', - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @ChardevVC: @@ -405,7 +405,7 @@ 'data': { '*mouse': 'bool', '*clipboard': 'bool' }, 'base': 'ChardevCommon', - 'if': 'defined(CONFIG_SPICE_PROTOCOL)' } + 'if': 'CONFIG_SPICE_PROTOCOL' } =20 ## # @ChardevBackend: @@ -431,11 +431,11 @@ 'stdio': 'ChardevStdio', 'console': 'ChardevCommon', 'spicevmc': { 'type': 'ChardevSpiceChannel', - 'if': 'defined(CONFIG_SPICE)' }, + 'if': 'CONFIG_SPICE' }, 'spiceport': { 'type': 'ChardevSpicePort', - 'if': 'defined(CONFIG_SPICE)' }, + 'if': 'CONFIG_SPICE' }, 'qemu-vdagent': { 'type': 'ChardevQemuVDAgent', - 'if': 'defined(CONFIG_SPICE_PROTOCOL)' }, + 'if': 'CONFIG_SPICE_PROTOCOL' }, 'vc': 'ChardevVC', 'ringbuf': 'ChardevRingbuf', # next one is just for compatibility diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 9b56b81bea..f5ec4bc172 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -89,7 +89,7 @@ ## { 'struct': 'CpuModelBaselineInfo', 'data': { 'model': 'CpuModelInfo' }, - 'if': 'defined(TARGET_S390X)' } + 'if': 'TARGET_S390X' } =20 ## # @CpuModelCompareInfo: @@ -112,7 +112,7 @@ { 'struct': 'CpuModelCompareInfo', 'data': { 'result': 'CpuModelCompareResult', 'responsible-properties': ['str'] }, - 'if': 'defined(TARGET_S390X)' } + 'if': 'TARGET_S390X' } =20 ## # @query-cpu-model-comparison: @@ -156,7 +156,7 @@ { 'command': 'query-cpu-model-comparison', 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, 'returns': 'CpuModelCompareInfo', - 'if': 'defined(TARGET_S390X)' } + 'if': 'TARGET_S390X' } =20 ## # @query-cpu-model-baseline: @@ -200,7 +200,7 @@ 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, 'returns': 'CpuModelBaselineInfo', - 'if': 'defined(TARGET_S390X)' } + 'if': 'TARGET_S390X' } =20 ## # @CpuModelExpansionInfo: @@ -213,9 +213,9 @@ ## { 'struct': 'CpuModelExpansionInfo', 'data': { 'model': 'CpuModelInfo' }, - 'if': { 'any': [ 'defined(TARGET_S390X)', - 'defined(TARGET_I386)', - 'defined(TARGET_ARM)'] } } + 'if': { 'any': [ 'TARGET_S390X', + 'TARGET_I386', + 'TARGET_ARM' ] } } =20 ## # @query-cpu-model-expansion: @@ -254,9 +254,9 @@ 'data': { 'type': 'CpuModelExpansionType', 'model': 'CpuModelInfo' }, 'returns': 'CpuModelExpansionInfo', - 'if': { 'any': [ 'defined(TARGET_S390X)', - 'defined(TARGET_I386)', - 'defined(TARGET_ARM)' ] } } + 'if': { 'any': [ 'TARGET_S390X', + 'TARGET_I386', + 'TARGET_ARM' ] } } =20 ## # @CpuDefinitionInfo: @@ -320,11 +320,11 @@ 'typename': 'str', '*alias-of' : 'str', 'deprecated' : 'bool' }, - 'if': { 'any': [ 'defined(TARGET_PPC)', - 'defined(TARGET_ARM)', - 'defined(TARGET_I386)', - 'defined(TARGET_S390X)', - 'defined(TARGET_MIPS)' ] } } + 'if': { 'any': [ 'TARGET_PPC', + 'TARGET_ARM', + 'TARGET_I386', + 'TARGET_S390X', + 'TARGET_MIPS' ] } } =20 ## # @query-cpu-definitions: @@ -336,8 +336,8 @@ # Since: 1.2 ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], - 'if': { 'any': [ 'defined(TARGET_PPC)', - 'defined(TARGET_ARM)', - 'defined(TARGET_I386)', - 'defined(TARGET_S390X)', - 'defined(TARGET_MIPS)' ] } } + 'if': { 'any': [ 'TARGET_PPC', + 'TARGET_ARM', + 'TARGET_I386', + 'TARGET_S390X', + 'TARGET_MIPS' ] } } diff --git a/qapi/migration.json b/qapi/migration.json index 1124a2dda8..88f07baedd 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -533,7 +533,7 @@ ## { 'enum': 'MultiFDCompression', 'data': [ 'none', 'zlib', - { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } + { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] } =20 ## # @BitmapMigrationBitmapAliasTransform: @@ -1562,7 +1562,7 @@ ## { 'command': 'xen-set-replication', 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' }, - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @ReplicationStatus: @@ -1578,7 +1578,7 @@ ## { 'struct': 'ReplicationStatus', 'data': { 'error': 'bool', '*desc': 'str' }, - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @query-xen-replication-status: @@ -1596,7 +1596,7 @@ ## { 'command': 'query-xen-replication-status', 'returns': 'ReplicationStatus', - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @xen-colo-do-checkpoint: @@ -1613,7 +1613,7 @@ # Since: 2.9 ## { 'command': 'xen-colo-do-checkpoint', - 'if': 'defined(CONFIG_REPLICATION)' } + 'if': 'CONFIG_REPLICATION' } =20 ## # @COLOStatus: diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 9e2ea4a04a..3b05ad3dbf 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -23,17 +23,17 @@ ## { 'event': 'RTC_CHANGE', 'data': { 'offset': 'int' }, - 'if': { 'any': [ 'defined(TARGET_ALPHA)', - 'defined(TARGET_ARM)', - 'defined(TARGET_HPPA)', - 'defined(TARGET_I386)', - 'defined(TARGET_MIPS)', - 'defined(TARGET_MIPS64)', - 'defined(TARGET_PPC)', - 'defined(TARGET_PPC64)', - 'defined(TARGET_S390X)', - 'defined(TARGET_SH4)', - 'defined(TARGET_SPARC)' ] } } + 'if': { 'any': [ 'TARGET_ALPHA', + 'TARGET_ARM', + 'TARGET_HPPA', + 'TARGET_I386', + 'TARGET_MIPS', + 'TARGET_MIPS64', + 'TARGET_PPC', + 'TARGET_PPC64', + 'TARGET_S390X', + 'TARGET_SH4', + 'TARGET_SPARC' ] } } =20 ## # @rtc-reset-reinjection: @@ -52,7 +52,7 @@ # ## { 'command': 'rtc-reset-reinjection', - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 =20 ## @@ -79,7 +79,7 @@ { 'enum': 'SevState', 'data': ['uninit', 'launch-update', 'launch-secret', 'running', 'send-update', 'receive-update' ], - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @SevInfo: @@ -111,7 +111,7 @@ 'state' : 'SevState', 'handle' : 'uint32' }, - 'if': 'defined(TARGET_I386)' + 'if': 'TARGET_I386' } =20 ## @@ -132,7 +132,7 @@ # ## { 'command': 'query-sev', 'returns': 'SevInfo', - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 =20 ## @@ -146,7 +146,7 @@ # ## { 'struct': 'SevLaunchMeasureInfo', 'data': {'data': 'str'}, - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @query-sev-launch-measure: @@ -164,7 +164,7 @@ # ## { 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo', - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 =20 ## @@ -189,7 +189,7 @@ 'cert-chain': 'str', 'cbitpos': 'int', 'reduced-phys-bits': 'int'}, - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @query-sev-capabilities: @@ -209,7 +209,7 @@ # ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability', - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @sev-inject-launch-secret: @@ -227,7 +227,7 @@ ## { 'command': 'sev-inject-launch-secret', 'data': { 'packet-header': 'str', 'secret': 'str', '*gpa': 'uint64' }, - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @dump-skeys: @@ -249,7 +249,7 @@ ## { 'command': 'dump-skeys', 'data': { 'filename': 'str' }, - 'if': 'defined(TARGET_S390X)' } + 'if': 'TARGET_S390X' } =20 ## # @GICCapability: @@ -274,7 +274,7 @@ 'data': { 'version': 'int', 'emulated': 'bool', 'kernel': 'bool' }, - 'if': 'defined(TARGET_ARM)' } + 'if': 'TARGET_ARM' } =20 ## # @query-gic-capabilities: @@ -294,7 +294,7 @@ # ## { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'], - 'if': 'defined(TARGET_ARM)' } + 'if': 'TARGET_ARM' } =20 =20 ## @@ -310,7 +310,7 @@ ## { 'struct': 'SevAttestationReport', 'data': { 'data': 'str'}, - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } =20 ## # @query-sev-attestation-report: @@ -332,4 +332,4 @@ ## { 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, 'returns': 'SevAttestationReport', - 'if': 'defined(TARGET_I386)' } + 'if': 'TARGET_I386' } diff --git a/qapi/qom.json b/qapi/qom.json index 6d5f4a88e6..a25616bc7a 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -618,7 +618,7 @@ 'data': { '*align': 'size', '*discard-data': 'bool', 'mem-path': 'str', - '*pmem': { 'type': 'bool', 'if': 'defined(CONFIG_LIBPMEM)' }, + '*pmem': { 'type': 'bool', 'if': 'CONFIG_LIBPMEM' }, '*readonly': 'bool' } } =20 ## @@ -782,7 +782,7 @@ 'cryptodev-backend', 'cryptodev-backend-builtin', { 'name': 'cryptodev-vhost-user', - 'if': 'defined(CONFIG_VHOST_CRYPTO)' }, + 'if': 'CONFIG_VHOST_CRYPTO' }, 'dbus-vmstate', 'filter-buffer', 'filter-dump', @@ -795,7 +795,7 @@ 'iothread', 'memory-backend-file', { 'name': 'memory-backend-memfd', - 'if': 'defined(CONFIG_LINUX)' }, + 'if': 'CONFIG_LINUX' }, 'memory-backend-ram', 'pef-guest', 'pr-manager-helper', @@ -840,7 +840,7 @@ 'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-vhost-user': { 'type': 'CryptodevVhostUserPropertie= s', - 'if': 'defined(CONFIG_VHOST_CRYPTO)'= }, + 'if': 'CONFIG_VHOST_CRYPTO' }, 'dbus-vmstate': 'DBusVMStateProperties', 'filter-buffer': 'FilterBufferProperties', 'filter-dump': 'FilterDumpProperties', @@ -853,7 +853,7 @@ 'iothread': 'IothreadProperties', 'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-memfd': { 'type': 'MemoryBackendMemfdPropertie= s', - 'if': 'defined(CONFIG_LINUX)' }, + 'if': 'CONFIG_LINUX' }, 'memory-backend-ram': 'MemoryBackendProperties', 'pr-manager-helper': 'PrManagerHelperProperties', 'qtest': 'QtestProperties', diff --git a/qapi/sockets.json b/qapi/sockets.json index 735eb4abb5..7866dc27d6 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -69,7 +69,7 @@ '*ipv4': 'bool', '*ipv6': 'bool', '*keep-alive': 'bool', - '*mptcp': { 'type': 'bool', 'if': 'defined(IPPROTO_MPTCP)' } } } + '*mptcp': { 'type': 'bool', 'if': 'IPPROTO_MPTCP' } } } =20 ## # @UnixSocketAddress: @@ -89,8 +89,8 @@ { 'struct': 'UnixSocketAddress', 'data': { 'path': 'str', - '*abstract': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' }, - '*tight': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' } } } + '*abstract': { 'type': 'bool', 'if': 'CONFIG_LINUX' }, + '*tight': { 'type': 'bool', 'if': 'CONFIG_LINUX' } } } =20 ## # @VsockSocketAddress: diff --git a/qapi/tpm.json b/qapi/tpm.json index 75590979fd..f4dde2f646 100644 --- a/qapi/tpm.json +++ b/qapi/tpm.json @@ -18,7 +18,7 @@ # Since: 1.5 ## { 'enum': 'TpmModel', 'data': [ 'tpm-tis', 'tpm-crb', 'tpm-spapr' ], - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @query-tpm-models: @@ -36,7 +36,7 @@ # ## { 'command': 'query-tpm-models', 'returns': ['TpmModel'], - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @TpmType: @@ -50,7 +50,7 @@ # Since: 1.5 ## { 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator' ], - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @query-tpm-types: @@ -68,7 +68,7 @@ # ## { 'command': 'query-tpm-types', 'returns': ['TpmType'], - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @TPMPassthroughOptions: @@ -85,7 +85,7 @@ { 'struct': 'TPMPassthroughOptions', 'data': { '*path': 'str', '*cancel-path': 'str' }, - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @TPMEmulatorOptions: @@ -97,7 +97,7 @@ # Since: 2.11 ## { 'struct': 'TPMEmulatorOptions', 'data': { 'chardev' : 'str' }, - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @TpmTypeOptions: @@ -112,7 +112,7 @@ { 'union': 'TpmTypeOptions', 'data': { 'passthrough' : 'TPMPassthroughOptions', 'emulator': 'TPMEmulatorOptions' }, - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @TPMInfo: @@ -131,7 +131,7 @@ 'data': {'id': 'str', 'model': 'TpmModel', 'options': 'TpmTypeOptions' }, - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } =20 ## # @query-tpm: @@ -162,4 +162,4 @@ # ## { 'command': 'query-tpm', 'returns': ['TPMInfo'], - 'if': 'defined(CONFIG_TPM)' } + 'if': 'CONFIG_TPM' } diff --git a/qapi/ui.json b/qapi/ui.json index aed2bec4ab..b2cf7a6759 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -123,7 +123,7 @@ 'data': { 'host': 'str', 'port': 'str', 'family': 'NetworkAddressFamily' }, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SpiceServerInfo: @@ -137,7 +137,7 @@ { 'struct': 'SpiceServerInfo', 'base': 'SpiceBasicInfo', 'data': { '*auth': 'str' }, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SpiceChannel: @@ -163,7 +163,7 @@ 'base': 'SpiceBasicInfo', 'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'i= nt', 'tls': 'bool'}, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SpiceQueryMouseMode: @@ -183,7 +183,7 @@ ## { 'enum': 'SpiceQueryMouseMode', 'data': [ 'client', 'server', 'unknown' ], - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SpiceInfo: @@ -222,7 +222,7 @@ 'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port':= 'int', '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str', 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChanne= l']}, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @query-spice: @@ -268,7 +268,7 @@ # ## { 'command': 'query-spice', 'returns': 'SpiceInfo', - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SPICE_CONNECTED: @@ -294,7 +294,7 @@ { 'event': 'SPICE_CONNECTED', 'data': { 'server': 'SpiceBasicInfo', 'client': 'SpiceBasicInfo' }, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SPICE_INITIALIZED: @@ -323,7 +323,7 @@ { 'event': 'SPICE_INITIALIZED', 'data': { 'server': 'SpiceServerInfo', 'client': 'SpiceChannel' }, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SPICE_DISCONNECTED: @@ -349,7 +349,7 @@ { 'event': 'SPICE_DISCONNECTED', 'data': { 'server': 'SpiceBasicInfo', 'client': 'SpiceBasicInfo' }, - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # @SPICE_MIGRATE_COMPLETED: @@ -365,7 +365,7 @@ # ## { 'event': 'SPICE_MIGRATE_COMPLETED', - 'if': 'defined(CONFIG_SPICE)' } + 'if': 'CONFIG_SPICE' } =20 ## # =3D=3D VNC @@ -393,7 +393,7 @@ 'service': 'str', 'family': 'NetworkAddressFamily', 'websocket': 'bool' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncServerInfo: @@ -408,7 +408,7 @@ { 'struct': 'VncServerInfo', 'base': 'VncBasicInfo', 'data': { '*auth': 'str' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncClientInfo: @@ -426,7 +426,7 @@ { 'struct': 'VncClientInfo', 'base': 'VncBasicInfo', 'data': { '*x509_dname': 'str', '*sasl_username': 'str' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncInfo: @@ -469,7 +469,7 @@ 'data': {'enabled': 'bool', '*host': 'str', '*family': 'NetworkAddressFamily', '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo'= ]}, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncPrimaryAuth: @@ -481,7 +481,7 @@ { 'enum': 'VncPrimaryAuth', 'data': [ 'none', 'vnc', 'ra2', 'ra2ne', 'tight', 'ultra', 'tls', 'vencrypt', 'sasl' ], - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncVencryptSubAuth: @@ -496,7 +496,7 @@ 'tls-vnc', 'x509-vnc', 'tls-plain', 'x509-plain', 'tls-sasl', 'x509-sasl' ], - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncServerInfo2: @@ -514,7 +514,7 @@ 'base': 'VncBasicInfo', 'data': { 'auth' : 'VncPrimaryAuth', '*vencrypt' : 'VncVencryptSubAuth' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VncInfo2: @@ -547,7 +547,7 @@ 'auth' : 'VncPrimaryAuth', '*vencrypt' : 'VncVencryptSubAuth', '*display' : 'str' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @query-vnc: @@ -579,7 +579,7 @@ # ## { 'command': 'query-vnc', 'returns': 'VncInfo', - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } ## # @query-vnc-servers: # @@ -590,7 +590,7 @@ # Since: 2.3 ## { 'command': 'query-vnc-servers', 'returns': ['VncInfo2'], - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @change-vnc-password: @@ -606,7 +606,7 @@ ## { 'command': 'change-vnc-password', 'data': { 'password': 'str' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VNC_CONNECTED: @@ -636,7 +636,7 @@ { 'event': 'VNC_CONNECTED', 'data': { 'server': 'VncServerInfo', 'client': 'VncBasicInfo' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VNC_INITIALIZED: @@ -664,7 +664,7 @@ { 'event': 'VNC_INITIALIZED', 'data': { 'server': 'VncServerInfo', 'client': 'VncClientInfo' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # @VNC_DISCONNECTED: @@ -691,7 +691,7 @@ { 'event': 'VNC_DISCONNECTED', 'data': { 'server': 'VncServerInfo', 'client': 'VncClientInfo' }, - 'if': 'defined(CONFIG_VNC)' } + 'if': 'CONFIG_VNC' } =20 ## # =3D Input @@ -1133,14 +1133,13 @@ 'data' : [ { 'name': 'default' }, { 'name': 'none' }, - { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' }, - { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' }, + { 'name': 'gtk', 'if': 'CONFIG_GTK' }, + { 'name': 'sdl', 'if': 'CONFIG_SDL' }, { 'name': 'egl-headless', - 'if': { 'all': [ 'defined(CONFIG_OPENGL)', - 'defined(CONFIG_GBM)' ] } }, - { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' }, - { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' }, - { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] } + 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, + { 'name': 'curses', 'if': 'CONFIG_CURSES' }, + { 'name': 'cocoa', 'if': 'CONFIG_COCOA' }, + { 'name': 'spice-app', 'if': 'CONFIG_SPICE'} ] } =20 ## # @DisplayOptions: @@ -1165,11 +1164,10 @@ '*gl' : 'DisplayGLMode' }, 'discriminator' : 'type', 'data' : { - 'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' }, - 'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' = }, + 'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' }, + 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', - 'if': { 'all': [ 'defined(CONFIG_OPENGL)', - 'defined(CONFIG_GBM)' ] } } + 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } } } } =20 diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index fb17eebde3..c60f5e669d 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1380,7 +1380,7 @@ 'data': { 'keys': ['str'] }, - 'if': 'defined(CONFIG_POSIX)' } + 'if': 'CONFIG_POSIX' } =20 =20 ## @@ -1398,7 +1398,7 @@ { 'command': 'guest-ssh-get-authorized-keys', 'data': { 'username': 'str' }, 'returns': 'GuestAuthorizedKeys', - 'if': 'defined(CONFIG_POSIX)' } + 'if': 'CONFIG_POSIX' } =20 ## # @guest-ssh-add-authorized-keys: @@ -1416,7 +1416,7 @@ ## { 'command': 'guest-ssh-add-authorized-keys', 'data': { 'username': 'str', 'keys': ['str'], '*reset': 'bool' }, - 'if': 'defined(CONFIG_POSIX)' } + 'if': 'CONFIG_POSIX' } =20 ## # @guest-ssh-remove-authorized-keys: @@ -1434,4 +1434,4 @@ ## { 'command': 'guest-ssh-remove-authorized-keys', 'data': { 'username': 'str', 'keys': ['str'] }, - 'if': 'defined(CONFIG_POSIX)' } + 'if': 'CONFIG_POSIX' } diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 3fb2fbe7d4..1724ac32db 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -204,7 +204,7 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> = str: if not ifcond: return '' if isinstance(ifcond, str): - return ifcond + return 'defined(' + ifcond + ')' =20 oper, operands =3D next(iter(ifcond.items())) if oper =3D=3D 'not': diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 120b31089f..019f4c97aa 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -275,10 +275,10 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo,= source: str) -> None: =20 def _check_if(cond: Union[str, object]) -> None: if isinstance(cond, str): - if not cond.strip(): + if not re.match(r'^[A-Z][A-Z0-9_]*$', cond): raise QAPISemError( info, - "'if' condition '%s' of %s makes no sense" + "'if' condition '%s' of %s is not a valid identifier" % (cond, source)) return =20 diff --git a/tests/qapi-schema/alternate-branch-if-invalid.err b/tests/qapi= -schema/alternate-branch-if-invalid.err index d384929c51..03bad877a3 100644 --- a/tests/qapi-schema/alternate-branch-if-invalid.err +++ b/tests/qapi-schema/alternate-branch-if-invalid.err @@ -1,2 +1,2 @@ alternate-branch-if-invalid.json: In alternate 'Alt': -alternate-branch-if-invalid.json:2: 'if' condition ' ' of 'data' member 'b= ranch' makes no sense +alternate-branch-if-invalid.json:2: 'if' condition ' ' of 'data' member 'b= ranch' is not a valid identifier diff --git a/tests/qapi-schema/bad-if-empty.err b/tests/qapi-schema/bad-if-= empty.err index a0f3effefb..5208f543ce 100644 --- a/tests/qapi-schema/bad-if-empty.err +++ b/tests/qapi-schema/bad-if-empty.err @@ -1,2 +1,2 @@ bad-if-empty.json: In struct 'TestIfStruct': -bad-if-empty.json:2: 'if' condition '' of struct makes no sense +bad-if-empty.json:2: 'if' condition '' of struct is not a valid identifier diff --git a/tests/qapi-schema/bad-if-list.err b/tests/qapi-schema/bad-if-l= ist.err index c462f11b90..334e8b845a 100644 --- a/tests/qapi-schema/bad-if-list.err +++ b/tests/qapi-schema/bad-if-list.err @@ -1,2 +1,2 @@ bad-if-list.json: In struct 'TestIfStruct': -bad-if-list.json:2: 'if' condition ' ' of struct makes no sense +bad-if-list.json:2: 'if' condition 'foo' of struct is not a valid identifi= er diff --git a/tests/qapi-schema/bad-if.json b/tests/qapi-schema/bad-if.json index fdc0c87bb3..2639e3c661 100644 --- a/tests/qapi-schema/bad-if.json +++ b/tests/qapi-schema/bad-if.json @@ -1,3 +1,3 @@ # check invalid 'if' type { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, - 'if': ['defined(TEST_IF_STRUCT)'] } + 'if': ['TEST_IF_STRUCT'] } diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 2a35c679a4..5e30790730 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -61,9 +61,9 @@ # @two is undocumented ## { 'enum': 'Enum', 'data': - [ { 'name': 'one', 'if': 'defined(IFONE)' }, 'two' ], + [ { 'name': 'one', 'if': 'IFONE' }, 'two' ], 'features': [ 'enum-feat' ], - 'if': 'defined(IFCOND)' } + 'if': 'IFCOND' } =20 ## # @Base: @@ -87,7 +87,7 @@ 'features': [ 'variant1-feat' ], 'data': { 'var1': { 'type': 'str', 'features': [ 'member-feat' ], - 'if': 'defined(IFSTR)' } } } + 'if': 'IFSTR' } } } =20 ## # @Variant2: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index a8871e8f99..26d1fa5d28 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -12,16 +12,16 @@ enum QType module doc-good.json enum Enum member one - if defined(IFONE) + if IFONE member two - if defined(IFCOND) + if IFCOND feature enum-feat object Base member base1: Enum optional=3DFalse if OrderedDict([('all', ['IFALL1', 'IFALL2'])]) object Variant1 member var1: str optional=3DFalse - if defined(IFSTR) + if IFSTR feature member-feat feature variant1-feat object Variant2 diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 03c98c4182..5bfe06e14e 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -43,7 +43,7 @@ Example: Values ~~~~~~ =20 -"one" (**If: **"defined(IFONE)") +"one" (**If: **"IFONE") The _one_ {and only} =20 "two" @@ -62,7 +62,7 @@ Features If ~~ =20 -"defined(IFCOND)" +"IFCOND" =20 =20 "Base" (Object) @@ -93,7 +93,7 @@ Another paragraph (but no "var": line) Members ~~~~~~~ =20 -"var1": "string" (**If: **"defined(IFSTR)") +"var1": "string" (**If: **"IFSTR") Not documented =20 =20 diff --git a/tests/qapi-schema/features-missing-name.json b/tests/qapi-sche= ma/features-missing-name.json index 2314f97c00..8772c8f7b3 100644 --- a/tests/qapi-schema/features-missing-name.json +++ b/tests/qapi-schema/features-missing-name.json @@ -1,3 +1,3 @@ { 'struct': 'FeatureStruct0', 'data': { 'foo': 'int' }, - 'features': [ { 'if': 'defined(NAMELESS_FEATURES)' } ] } + 'features': [ { 'if': 'NAMELESS_FEATURES' } ] } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index a700f2531b..fe028145e4 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -222,45 +222,45 @@ =20 { 'struct': 'TestIfStruct', 'data': { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'defined(TEST_IF_STRUCT_BAR)'} }, - 'if': 'defined(TEST_IF_STRUCT)' } + 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} }, + 'if': 'TEST_IF_STRUCT' } =20 { 'enum': 'TestIfEnum', 'data': - [ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ], - 'if': 'defined(TEST_IF_ENUM)' } + [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], + 'if': 'TEST_IF_ENUM' } =20 { 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct', - 'bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, - 'if': { 'all': ['defined(TEST_IF_UNION)', 'defined(TEST_IF_STRUCT)'] } } + 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, + 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-union-cmd', 'data': { 'union-cmd-arg': 'TestIfUnion' }, - 'if': 'defined(TEST_IF_UNION)' } + 'if': 'TEST_IF_UNION' } =20 { 'alternate': 'TestIfAlternate', 'data': { 'foo': 'int', - 'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} }, - 'if': { 'all': ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRUCT)'] } } + 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} }, + 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-alternate-cmd', 'data': { 'alt-cmd-arg': 'TestIfAlternate' }, - 'if': { 'all': ['defined(TEST_IF_ALT)', - {'not': 'defined(TEST_IF_NOT_ALT)'}] } } + 'if': { 'all': ['TEST_IF_ALT', + {'not': 'TEST_IF_NOT_ALT'}] } } =20 { 'command': 'test-if-cmd', 'data': { 'foo': 'TestIfStruct', - 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } }, + 'bar': { 'type': 'TestIfEnum', 'if': 'TEST_IF_CMD_BAR' } }, 'returns': 'UserDefThree', - 'if': { 'all': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] } } + 'if': { 'all': ['TEST_IF_CMD', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } =20 { 'event': 'TEST_IF_EVENT', 'data': { 'foo': 'TestIfStruct', - 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, - 'if': { 'all': ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRUCT)'] } } + 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, + 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } } =20 # test 'features' =20 @@ -282,21 +282,21 @@ =20 { 'struct': 'CondFeatureStruct1', 'data': { 'foo': 'int' }, - 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} = ] } + 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] } { 'struct': 'CondFeatureStruct2', 'data': { 'foo': 'int' }, - 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, - { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} = ] } + 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'}, + { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] } { 'struct': 'CondFeatureStruct3', 'data': { 'foo': 'int' }, 'features': [ { 'name': 'feature1', - 'if': { 'all': [ 'defined(TEST_IF_COND_1)', - 'defined(TEST_IF_COND_2)'] } } ] } + 'if': { 'all': [ 'TEST_IF_COND_1', + 'TEST_IF_COND_2'] } } ] } { 'struct': 'CondFeatureStruct4', 'data': { 'foo': 'int' }, 'features': [ { 'name': 'feature1', - 'if': {'any': ['defined(TEST_IF_COND_1)', - 'defined(TEST_IF_COND_2)'] } } ] } + 'if': {'any': ['TEST_IF_COND_1', + 'TEST_IF_COND_2'] } } ] } =20 { 'enum': 'FeatureEnum1', 'data': [ 'eins', 'zwei', 'drei' ], @@ -331,14 +331,14 @@ 'features': [ 'feature1', 'feature2' ] } =20 { 'command': 'test-command-cond-features1', - 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} = ] } + 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] } { 'command': 'test-command-cond-features2', - 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, - { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} = ] } + 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'}, + { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] } { 'command': 'test-command-cond-features3', 'features': [ { 'name': 'feature1', - 'if': { 'all': [ 'defined(TEST_IF_COND_1)', - 'defined(TEST_IF_COND_2)'] } } ] } + 'if': { 'all': [ 'TEST_IF_COND_1', + 'TEST_IF_COND_2'] } } ] } =20 { 'event': 'TEST_EVENT_FEATURES0', 'data': 'FeatureStruct1' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 53e12f3534..3d0c6a8f28 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -298,65 +298,65 @@ command __org.qemu_x-command q_obj___org.qemu_x-comma= nd-arg -> __org.qemu_x-Unio object TestIfStruct member foo: int optional=3DFalse member bar: int optional=3DFalse - if defined(TEST_IF_STRUCT_BAR) - if defined(TEST_IF_STRUCT) + if TEST_IF_STRUCT_BAR + if TEST_IF_STRUCT enum TestIfEnum member foo member bar - if defined(TEST_IF_ENUM_BAR) - if defined(TEST_IF_ENUM) + if TEST_IF_ENUM_BAR + if TEST_IF_ENUM object q_obj_TestStruct-wrapper member data: TestStruct optional=3DFalse enum TestIfUnionKind member foo member bar - if defined(TEST_IF_UNION_BAR) - if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_ST= RUCT)'])]) + if TEST_IF_UNION_BAR + if OrderedDict([('all', ['TEST_IF_UNION', 'TEST_IF_STRUCT'])]) object TestIfUnion member type: TestIfUnionKind optional=3DFalse tag type case foo: q_obj_TestStruct-wrapper case bar: q_obj_str-wrapper - if defined(TEST_IF_UNION_BAR) - if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_ST= RUCT)'])]) + if TEST_IF_UNION_BAR + if OrderedDict([('all', ['TEST_IF_UNION', 'TEST_IF_STRUCT'])]) object q_obj_test-if-union-cmd-arg member union-cmd-arg: TestIfUnion optional=3DFalse - if defined(TEST_IF_UNION) + if TEST_IF_UNION command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if defined(TEST_IF_UNION) + if TEST_IF_UNION alternate TestIfAlternate tag type case foo: int case bar: TestStruct - if defined(TEST_IF_ALT_BAR) - if OrderedDict([('all', ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRU= CT)'])]) + if TEST_IF_ALT_BAR + if OrderedDict([('all', ['TEST_IF_ALT', 'TEST_IF_STRUCT'])]) object q_obj_test-if-alternate-cmd-arg member alt-cmd-arg: TestIfAlternate optional=3DFalse - if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', = 'defined(TEST_IF_NOT_ALT)')])])]) + if OrderedDict([('all', ['TEST_IF_ALT', OrderedDict([('not', 'TEST_IF_= NOT_ALT')])])]) command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', = 'defined(TEST_IF_NOT_ALT)')])])]) + if OrderedDict([('all', ['TEST_IF_ALT', OrderedDict([('not', 'TEST_IF_= NOT_ALT')])])]) object q_obj_test-if-cmd-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse - if defined(TEST_IF_CMD_BAR) - if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRU= CT)'])]) + if TEST_IF_CMD_BAR + if OrderedDict([('all', ['TEST_IF_CMD', 'TEST_IF_STRUCT'])]) command test-if-cmd q_obj_test-if-cmd-arg -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse - if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRU= CT)'])]) + if OrderedDict([('all', ['TEST_IF_CMD', 'TEST_IF_STRUCT'])]) command test-cmd-return-def-three None -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse array TestIfEnumList TestIfEnum - if defined(TEST_IF_ENUM) + if TEST_IF_ENUM object q_obj_TEST_IF_EVENT-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnumList optional=3DFalse - if defined(TEST_IF_EVT_BAR) - if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRU= CT)'])]) + if TEST_IF_EVT_BAR + if OrderedDict([('all', ['TEST_IF_EVT', 'TEST_IF_STRUCT'])]) event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg boxed=3DFalse - if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRU= CT)'])]) + if OrderedDict([('all', ['TEST_IF_EVT', 'TEST_IF_STRUCT'])]) object FeatureStruct0 member foo: int optional=3DFalse object FeatureStruct1 @@ -379,21 +379,21 @@ object FeatureStruct4 object CondFeatureStruct1 member foo: int optional=3DFalse feature feature1 - if defined(TEST_IF_FEATURE_1) + if TEST_IF_FEATURE_1 object CondFeatureStruct2 member foo: int optional=3DFalse feature feature1 - if defined(TEST_IF_FEATURE_1) + if TEST_IF_FEATURE_1 feature feature2 - if defined(TEST_IF_FEATURE_2) + if TEST_IF_FEATURE_2 object CondFeatureStruct3 member foo: int optional=3DFalse feature feature1 - if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) + if OrderedDict([('all', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])]) object CondFeatureStruct4 member foo: int optional=3DFalse feature feature1 - if OrderedDict([('any', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) + if OrderedDict([('any', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])]) enum FeatureEnum1 member eins member zwei @@ -434,17 +434,17 @@ command test-command-features3 None -> None command test-command-cond-features1 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 - if defined(TEST_IF_FEATURE_1) + if TEST_IF_FEATURE_1 command test-command-cond-features2 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 - if defined(TEST_IF_FEATURE_1) + if TEST_IF_FEATURE_1 feature feature2 - if defined(TEST_IF_FEATURE_2) + if TEST_IF_FEATURE_2 command test-command-cond-features3 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 - if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_= IF_COND_2)'])]) + if OrderedDict([('all', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])]) event TEST_EVENT_FEATURES0 FeatureStruct1 boxed=3DFalse event TEST_EVENT_FEATURES1 None diff --git a/tests/qapi-schema/redefined-event.json b/tests/qapi-schema/red= efined-event.json index 09eff18412..7901930e3d 100644 --- a/tests/qapi-schema/redefined-event.json +++ b/tests/qapi-schema/redefined-event.json @@ -1,3 +1,3 @@ # we reject duplicate events { 'event': 'EVENT_A', 'data': { 'myint': 'int' } } -{ 'event': 'EVENT_A', 'data': { 'myint': 'int' }, 'if': 'defined(FOO)' } +{ 'event': 'EVENT_A', 'data': { 'myint': 'int' }, 'if': 'FOO' } diff --git a/tests/qapi-schema/union-branch-if-invalid.err b/tests/qapi-sch= ema/union-branch-if-invalid.err index dd4518233e..046187a5b9 100644 --- a/tests/qapi-schema/union-branch-if-invalid.err +++ b/tests/qapi-schema/union-branch-if-invalid.err @@ -1,2 +1,2 @@ union-branch-if-invalid.json: In union 'Uni': -union-branch-if-invalid.json:4: 'if' condition '' of 'data' member 'branch= 1' makes no sense +union-branch-if-invalid.json:4: 'if' condition '' of 'data' member 'branch= 1' is not a valid identifier --=20 2.31.1