From patchwork Mon May 6 11:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0576C41513 for ; Mon, 6 May 2024 11:04:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7n-00031T-7y; Mon, 06 May 2024 07:03:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7c-0002nZ-No for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003eM-3Z for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993377; 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=5JZJZ30hoscIH0XNsfxJED2r8MoVXpLdGJjt1EwEL8U=; b=gVpOlkObevYITTEo+uQMi2s6mjjEpVRDlNzKt7/0njpdzRzvd90QKfhM29lUqefemN5lFB D2wsllPt301BFFaOqhL/ka9bGjYYp/hfuzyidmF0KFJomXfehEGC6qKcJOLt4Y6/UNodBt ZjJcbpbKlEvaH3DJs76olG5a6SctwnA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-G7oR9L_aOzWqLiVx15g5VQ-1; Mon, 06 May 2024 07:02:55 -0400 X-MC-Unique: G7oR9L_aOzWqLiVx15g5VQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 797C138000AF; Mon, 6 May 2024 11:02:55 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 273272024511; Mon, 6 May 2024 11:02:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3989F21E669D; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PULL 1/7] qapi: New QAPISchemaBranches, QAPISchemaAlternatives Date: Mon, 6 May 2024 13:02:41 +0200 Message-ID: <20240506110254.3965097-2-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org QAPISchemaVariants represents either a union type's branches, or an alternate type's alternatives. Much of its code is conditional on which one it actually is. Create QAPISchemaBranches for branches, and QAPISchemaAlternatives for alternatives, both subtypes of QAPISchemaVariants. Replace QAPISchemaVariants by one of them where possible. Keep it only where we actually deal with either of them. QAPISchemaVariants.__init__() takes @tag_name and @tag_member, where exactly one must be None: @tag_name for alternatives, @tag_member for branches. Let QAPISchemaBranches.__init__() take just @tag_name, and QAPISchemaAlternatives.__init__() take just @tag_member. A later patch will move the conditional code to the subtypes. Signed-off-by: Markus Armbruster --- scripts/qapi/introspect.py | 7 ++++--- scripts/qapi/schema.py | 32 ++++++++++++++++++++++++-------- scripts/qapi/types.py | 6 ++++-- scripts/qapi/visit.py | 11 ++++++----- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 4679b1bc2c..b866517942 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -26,6 +26,8 @@ from .gen import QAPISchemaMonolithicCVisitor from .schema import ( QAPISchema, + QAPISchemaAlternatives, + QAPISchemaBranches, QAPISchemaArrayType, QAPISchemaBuiltinType, QAPISchemaEntity, @@ -36,7 +38,6 @@ QAPISchemaObjectTypeMember, QAPISchemaType, QAPISchemaVariant, - QAPISchemaVariants, ) from .source import QAPISourceInfo @@ -335,7 +336,7 @@ def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants]) -> None: + variants: Optional[QAPISchemaBranches]) -> None: obj: SchemaInfoObject = { 'members': [self._gen_object_member(m) for m in members] } @@ -347,7 +348,7 @@ def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo], def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaVariants) -> None: + variants: QAPISchemaAlternatives) -> None: self._gen_tree( name, 'alternate', {'members': [Annotated({'type': self._use_type(m.type)}, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 5924947fc3..5cdedfc2c8 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -215,7 +215,7 @@ def visit_object_type( features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants], + variants: Optional[QAPISchemaBranches], ) -> None: pass @@ -226,7 +226,7 @@ def visit_object_type_flat( ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants], + variants: Optional[QAPISchemaBranches], ) -> None: pass @@ -236,7 +236,7 @@ def visit_alternate_type( info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaVariants, + variants: QAPISchemaAlternatives, ) -> None: pass @@ -524,7 +524,7 @@ def __init__( features: Optional[List[QAPISchemaFeature]], base: Optional[str], local_members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants], + variants: Optional[QAPISchemaBranches], ): # struct has local_members, optional base, and no variants # union has base, variants, and no local_members @@ -651,7 +651,7 @@ def __init__( doc: Optional[QAPIDoc], ifcond: Optional[QAPISchemaIfCond], features: List[QAPISchemaFeature], - variants: QAPISchemaVariants, + variants: QAPISchemaAlternatives, ): super().__init__(name, info, doc, ifcond, features) assert variants.tag_member @@ -833,6 +833,22 @@ def check_clash( v.type.check_clash(info, dict(seen)) +class QAPISchemaBranches(QAPISchemaVariants): + def __init__(self, + info: QAPISourceInfo, + variants: List[QAPISchemaVariant], + tag_name: str): + super().__init__(tag_name, info, None, variants) + + +class QAPISchemaAlternatives(QAPISchemaVariants): + def __init__(self, + info: QAPISourceInfo, + variants: List[QAPISchemaVariant], + tag_member: QAPISchemaObjectTypeMember): + super().__init__(None, info, tag_member, variants) + + class QAPISchemaMember: """ Represents object members, enum members and features """ role = 'member' @@ -1388,8 +1404,8 @@ def _def_union_type(self, expr: QAPIExpression) -> None: self._def_definition( QAPISchemaObjectType(name, info, expr.doc, ifcond, features, base, members, - QAPISchemaVariants( - tag_name, info, None, variants))) + QAPISchemaBranches( + info, variants, tag_name))) def _def_alternate_type(self, expr: QAPIExpression) -> None: name = expr['alternate'] @@ -1407,7 +1423,7 @@ def _def_alternate_type(self, expr: QAPIExpression) -> None: self._def_definition( QAPISchemaAlternateType( name, info, expr.doc, ifcond, features, - QAPISchemaVariants(None, info, tag_member, variants))) + QAPISchemaAlternatives(info, variants, tag_member))) def _def_command(self, expr: QAPIExpression) -> None: name = expr['command'] diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index c39d054d2c..23cdf3e83e 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -23,6 +23,8 @@ ) from .schema import ( QAPISchema, + QAPISchemaAlternatives, + QAPISchemaBranches, QAPISchemaEnumMember, QAPISchemaFeature, QAPISchemaIfCond, @@ -348,7 +350,7 @@ def visit_object_type(self, features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants]) -> None: + variants: Optional[QAPISchemaBranches]) -> None: # Nothing to do for the special empty builtin if name == 'q_empty': return @@ -369,7 +371,7 @@ def visit_alternate_type(self, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaVariants) -> None: + variants: QAPISchemaAlternatives) -> None: with ifcontext(ifcond, self._genh): self._genh.preamble_add(gen_fwd_object_or_array(name)) self._genh.add(gen_object(name, ifcond, None, diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index a21b7b1468..990685498f 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -28,6 +28,8 @@ ) from .schema import ( QAPISchema, + QAPISchemaAlternatives, + QAPISchemaBranches, QAPISchemaEnumMember, QAPISchemaEnumType, QAPISchemaFeature, @@ -35,7 +37,6 @@ QAPISchemaObjectType, QAPISchemaObjectTypeMember, QAPISchemaType, - QAPISchemaVariants, ) from .source import QAPISourceInfo @@ -63,7 +64,7 @@ def gen_visit_members_decl(name: str) -> str: def gen_visit_object_members(name: str, base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants]) -> str: + variants: Optional[QAPISchemaBranches]) -> str: ret = mcgen(''' bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) @@ -222,7 +223,7 @@ def gen_visit_enum(name: str) -> str: c_name=c_name(name)) -def gen_visit_alternate(name: str, variants: QAPISchemaVariants) -> str: +def gen_visit_alternate(name: str, variants: QAPISchemaAlternatives) -> str: ret = mcgen(''' bool visit_type_%(c_name)s(Visitor *v, const char *name, @@ -393,7 +394,7 @@ def visit_object_type(self, features: List[QAPISchemaFeature], base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants]) -> None: + variants: Optional[QAPISchemaBranches]) -> None: # Nothing to do for the special empty builtin if name == 'q_empty': return @@ -413,7 +414,7 @@ def visit_alternate_type(self, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaVariants) -> None: + variants: QAPISchemaAlternatives) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_alternate(name, variants)) From patchwork Mon May 6 11:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DF12C10F16 for ; Mon, 6 May 2024 11:07:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7l-0002xo-8K; Mon, 06 May 2024 07:03:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7f-0002oU-0N for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003f7-Lo for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993379; 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=CST8hJi+JjS3q3FB4kEBCJTRkwPPNE8vTTYwVXxChSI=; b=S8/x6wdGScAlwYR2TWjfskEZ/UvB+l5uwyxhyJsb/LYgI745ZkANLKndT2PXjBDc1X25eP I+4JZewszX1MQEqbJfDQYETjHfG+Zr6jwVXyCP2Q2GUVq68cFuKY5htX1O/PGE3tY0UKQV wMK9PWm4b00w8OF1DyIcUSJeQVR/tSk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-49-AkeHUL-kN5CdO1Kjl6AW5Q-1; Mon, 06 May 2024 07:02:55 -0400 X-MC-Unique: AkeHUL-kN5CdO1Kjl6AW5Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EE3C80BB33; Mon, 6 May 2024 11:02:55 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27419EC683; Mon, 6 May 2024 11:02:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 41F3621E64D0; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 2/7] sphinx/qapidoc: Tweak "Since" section formatting WIP Date: Mon, 6 May 2024 13:02:44 +0200 Message-ID: <20240506110254.3965097-5-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --- docs/sphinx/qapidoc.py | 6 +++--- tests/qapi-schema/doc-good.txt | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index ac81003f0e..f19f5ded78 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -252,9 +252,9 @@ def _nodes_for_features(self, doc): def _nodes_for_since(self, doc): if doc.since: - section = self._make_section('Since') - self._parse_text_into_node(doc.since.text, section) - return [section] + # TODO emphasis + return [nodes.paragraph( + '', '', nodes.Text('Since: ' + doc.since.text))] return [] def _nodes_for_example(self, exampletext): diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 847db70412..56d50d4992 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -235,11 +235,7 @@ Examples - *verbatim* - {braces} - -Since -~~~~~ - -2.10 +Since: 2.10 "cmd-boxed" (Command) From patchwork Mon May 6 11:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5C52C25B5F for ; Mon, 6 May 2024 11:05:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7m-0002zK-0Z; Mon, 06 May 2024 07:03:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7a-0002lJ-T9 for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003el-72 for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993378; 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=nyVLHeduWKWXEcXc63nmjHd8vIqUBrwtESlJ8J+9mrE=; b=jKcSxXcgQwSHvoGDOS5shKzkhoiFKhbjjqZSpO2dLRAxnUuY2dsyiXS/HKg1bPuGTvBufg wmqOiyD32U6uXguTf7BdH6/tWvN/tBT0j53nnr5F8E9yQmhPGfHRY7mPhWz6C6dR0SWRNU Fkalgsm8VuZL00ZP3gyzMncBGcSE8TY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-TFMCNSlzOlOcjxevfjiX3w-1; Mon, 06 May 2024 07:02:57 -0400 X-MC-Unique: TFMCNSlzOlOcjxevfjiX3w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92B2918065AD; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58036C13FA1; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 44D0521E6142; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PULL 3/7] qapi: Rename visitor parameter @variants to @alternatives Date: Mon, 6 May 2024 13:02:45 +0200 Message-ID: <20240506110254.3965097-6-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org A previous commit narrowed the type of .visit_alternate_type() parameter @variants from QAPISchemaVariants to QAPISchemaAlternatives. Rename it to @alternatives. One of them passes @alternatives to helper function gen_visit_alternate(). Rename its @variants parameter to @alternatives as well. Signed-off-by: Markus Armbruster --- docs/sphinx/qapidoc.py | 3 ++- scripts/qapi/introspect.py | 4 ++-- scripts/qapi/schema.py | 2 +- scripts/qapi/types.py | 4 ++-- scripts/qapi/visit.py | 9 +++++---- tests/qapi-schema/test-qapi.py | 5 +++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index 71362ba929..f270b494f0 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -318,7 +318,8 @@ def visit_object_type(self, name, info, ifcond, features, + self._nodes_for_sections(doc) + self._nodes_for_if_section(ifcond)) - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, name, info, ifcond, features, + alternatives): doc = self._cur_doc self._add_doc('Alternate', self._nodes_for_members(doc, 'Members') diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 7852591490..86c075a6ad 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -348,12 +348,12 @@ def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo], def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaAlternatives) -> None: + alternatives: QAPISchemaAlternatives) -> None: self._gen_tree( name, 'alternate', {'members': [Annotated({'type': self._use_type(m.type)}, m.ifcond) - for m in variants.variants]}, + for m in alternatives.variants]}, ifcond, features ) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 65c82dd4f1..2b67992aee 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -236,7 +236,7 @@ def visit_alternate_type( info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaAlternatives, + alternatives: QAPISchemaAlternatives, ) -> None: pass diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 0abb78f3a8..69f5f6ffd0 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -371,11 +371,11 @@ def visit_alternate_type(self, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaAlternatives) -> None: + alternatives: QAPISchemaAlternatives) -> None: with ifcontext(ifcond, self._genh): self._genh.preamble_add(gen_fwd_object_or_array(name)) self._genh.add(gen_object(name, ifcond, None, - [variants.tag_member], variants)) + [alternatives.tag_member], alternatives)) with ifcontext(ifcond, self._genh, self._genc): self._gen_type_cleanup(name) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index fbae5f3e4e..e766acaac9 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -223,7 +223,8 @@ def gen_visit_enum(name: str) -> str: c_name=c_name(name)) -def gen_visit_alternate(name: str, variants: QAPISchemaAlternatives) -> str: +def gen_visit_alternate(name: str, + alternatives: QAPISchemaAlternatives) -> str: ret = mcgen(''' bool visit_type_%(c_name)s(Visitor *v, const char *name, @@ -245,7 +246,7 @@ def gen_visit_alternate(name: str, variants: QAPISchemaAlternatives) -> str: ''', c_name=c_name(name)) - for var in variants.variants: + for var in alternatives.variants: ret += var.ifcond.gen_if() ret += mcgen(''' case %(case)s: @@ -414,10 +415,10 @@ def visit_alternate_type(self, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaAlternatives) -> None: + alternatives: QAPISchemaAlternatives) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) - self._genc.add(gen_visit_alternate(name, variants)) + self._genc.add(gen_visit_alternate(name, alternatives)) def gen_visit(schema: QAPISchema, diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 7c67ad8d9b..7e3f9f4aa1 100755 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -61,9 +61,10 @@ def visit_object_type(self, name, info, ifcond, features, self._print_if(ifcond) self._print_features(features) - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, name, info, ifcond, features, + alternatives): print('alternate %s' % name) - self._print_variants(variants) + self._print_variants(alternatives) self._print_if(ifcond) self._print_features(features) From patchwork Mon May 6 11:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB032C10F16 for ; Mon, 6 May 2024 11:04:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7i-0002oV-DT; Mon, 06 May 2024 07:03:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7a-0002lH-GW for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003ev-6x for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993378; 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=RQjvMBOGkZJAZ6BlA2e5WXO5nMwzNQx1Bsbo/JjuGDE=; b=OcvAlFW9/87UvLDaWvgABTuyA5bcworkHuAMvZ0i6omaZSSO5nJZxK4d00+CHX7TopGV7m 3F+Ywhkg5x5g1WNq7PJ8wyvtM5MRcQk8nLC/i+23uKiVbSGI++6/SdGv1xBsfJSR9hSWXG Y9crC+RlhDMK1ymTmJloBtfZJcjvZr8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-mUvFnuv8N3WVHTzmyL9Eyw-1; Mon, 06 May 2024 07:02:57 -0400 X-MC-Unique: mUvFnuv8N3WVHTzmyL9Eyw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2D5818065B3; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A322A49102; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4D53921E5D2A; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 4/7] qapidoc: Generate default Returns WIP Date: Mon, 6 May 2024 13:02:48 +0200 Message-ID: <20240506110254.3965097-9-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Affected: x-debug-query-block-graph query-tpm query-dirty-rate query-vcpu-dirty-limit query-vm-generation-id query-memory-size-summary query-memory-devices query-acpi-ospm-status query-stats-schemas --- docs/sphinx/qapidoc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index 24bf1d9a90..35627ca741 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -251,9 +251,14 @@ def _nodes_for_features(self, doc): return [section] def _nodes_for_returns(self, doc, ret_type): - if doc.returns: + assert not doc.returns or ret_type + if ret_type: section = self._make_section('Returns') - self._parse_text_into_node(doc.returns.text, section) + if doc.returns: + self._parse_text_into_node(doc.returns.text, section) + else: + section += nodes.paragraph( + '', '', nodes.Text(ret_type.doc_type())) return [section] return [] From patchwork Mon May 6 11:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EEF7AC25B5F for ; Mon, 6 May 2024 11:06:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7i-0002ps-TM; Mon, 06 May 2024 07:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7d-0002nb-BJ for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003en-3Z for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993378; 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=et+/ntzRn8KKOw7HyPbGWlfdTlKfnZsjoA4xRTtetQg=; b=ffRJwpzijaIozsgXXoswl4ChBAn8F7K00yhSax8+uTFBq548Q1hs0BrMNBkRLVCkMC4W2h lsulV2YH51Wz6yO0cCW6Dmnpb9t8KvkxGDhxfpWAGGlHyG6BvgB0EkdFq5uPV3KDU/8m2M UbRMCz2PtaNZqBQ7vM9uW8uXLf9ASbk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-crcPYp2FMLaeCxuZVTs6yQ-1; Mon, 06 May 2024 07:02:57 -0400 X-MC-Unique: crcPYp2FMLaeCxuZVTs6yQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE13080B70A; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57DDA492BC7; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5060321E5D2B; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 5/7] qapi: Drop "Returns" section where default is fine WIP Date: Mon, 6 May 2024 13:02:49 +0200 Message-ID: <20240506110254.3965097-10-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --- qapi/audio.json | 2 -- qapi/block-core.json | 21 ++++----------------- qapi/block-export.json | 2 +- qapi/block.json | 3 --- qapi/char.json | 10 +--------- qapi/control.json | 5 ----- qapi/cryptodev.json | 2 -- qapi/dump.json | 5 ----- qapi/job.json | 2 -- qapi/machine-target.json | 6 ++---- qapi/machine.json | 36 ------------------------------------ qapi/migration.json | 12 ------------ qapi/misc-target.json | 16 ---------------- qapi/misc.json | 16 ++-------------- qapi/pci.json | 2 +- qapi/qdev.json | 3 --- qapi/qom.json | 8 -------- qapi/replay.json | 2 -- qapi/rocker.json | 8 -------- qapi/run-state.json | 2 -- qapi/stats.json | 2 +- qapi/tpm.json | 4 ---- qapi/trace.json | 5 ++--- qapi/ui.json | 10 ---------- qapi/virtio.json | 10 ---------- qapi/yank.json | 2 -- 26 files changed, 14 insertions(+), 182 deletions(-) diff --git a/qapi/audio.json b/qapi/audio.json index 519697c0cd..bf11ca6d0a 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -515,8 +515,6 @@ # # Returns information about audiodev configuration # -# Returns: array of @Audiodev -# # Since: 8.0 ## { 'command': 'query-audiodevs', diff --git a/qapi/block-core.json b/qapi/block-core.json index 746d1694c2..fab1a45365 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -757,10 +757,8 @@ ## # @query-block: # -# Get a list of BlockInfo for all virtual block devices. -# -# Returns: a list of @BlockInfo describing each virtual block device. -# Filter nodes that were created implicitly are skipped over. +# Get a list of BlockInfo for all virtual block devices. Filter nodes +# that were created implicitly are skipped over. # # Since: 0.14 # @@ -1164,8 +1162,6 @@ # that were created implicitly are skipped over in this mode. # (Since 2.3) # -# Returns: A list of @BlockStats for each virtual block devices. -# # Since: 0.14 # # Example: @@ -1434,9 +1430,8 @@ ## # @query-block-jobs: # -# Return information about long-running block device operations. -# -# Returns: a list of @BlockJobInfo for each active block job +# Return information about active, long-running block device +# operations ("block jobs"). # # Since: 1.1 ## @@ -1941,8 +1936,6 @@ # @flat: Omit the nested data about backing image ("backing-image" # key) if true. Default is false (Since 5.0) # -# Returns: the list of BlockDeviceInfo -# # Since: 2.0 # # Example: @@ -2456,9 +2449,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: -# BlockDirtyBitmapSha256 -# # Errors: # - If @node is not a valid block device, DeviceNotFound # - If @name is not found or if hashing has failed, GenericError @@ -6100,9 +6090,6 @@ # # @name: optional the snapshot's name to be deleted # -# Returns: -# SnapshotInfo -# # Errors: # - If @device is not a valid block device, GenericError # - If snapshot not found, GenericError diff --git a/qapi/block-export.json b/qapi/block-export.json index 3919a2d5b9..89a277db80 100644 --- a/qapi/block-export.json +++ b/qapi/block-export.json @@ -464,7 +464,7 @@ ## # @query-block-exports: # -# Returns: A list of BlockExportInfo describing all block exports +# Query block export information. # # Since: 5.2 ## diff --git a/qapi/block.json b/qapi/block.json index 5de99fe09d..97e2ccc4f1 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -86,9 +86,6 @@ # Returns a list of information about each persistent reservation # manager. # -# Returns: a list of @PRManagerInfo for each persistent reservation -# manager -# # Since: 3.0 ## { 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'], diff --git a/qapi/char.json b/qapi/char.json index 777dde55d9..87e1523946 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -36,8 +36,6 @@ # # Returns information about current character devices. # -# Returns: a list of @ChardevInfo -# # Since: 0.14 # # Example: @@ -82,8 +80,6 @@ # # Returns information about character device backends. # -# Returns: a list of @ChardevBackendInfo -# # Since: 2.0 # # Example: @@ -173,7 +169,7 @@ # - The return value is always Unicode regardless of format, like # any other string. # -# Returns: data read from the device +# Returns: data read from the device (string) # # Since: 1.4 # @@ -695,8 +691,6 @@ # # @backend: backend type and parameters # -# Returns: ChardevReturn. -# # Since: 1.4 # # Examples: @@ -731,8 +725,6 @@ # # @backend: new backend type and parameters # -# Returns: ChardevReturn. -# # Since: 2.10 # # Examples: diff --git a/qapi/control.json b/qapi/control.json index 6bdbf077c2..39510430fc 100644 --- a/qapi/control.json +++ b/qapi/control.json @@ -93,9 +93,6 @@ # # Returns the current version of QEMU. # -# Returns: A @VersionInfo object describing the current version of -# QEMU. -# # Since: 0.14 # # Example: @@ -131,8 +128,6 @@ # # Return a list of supported QMP commands by this server # -# Returns: A list of @CommandInfo for all supported commands -# # Since: 0.14 # # Example: diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 68289f4984..6707aa506f 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -89,8 +89,6 @@ # # Returns information about current crypto devices. # -# Returns: a list of @QCryptodevInfo -# # Since: 8.0 ## { 'command': 'query-cryptodev', 'returns': ['QCryptodevInfo']} diff --git a/qapi/dump.json b/qapi/dump.json index 2fa9504d86..ec18387c71 100644 --- a/qapi/dump.json +++ b/qapi/dump.json @@ -146,8 +146,6 @@ # # Query latest dump status. # -# Returns: A @DumpStatus object showing the dump status. -# # Since: 2.6 # # Example: @@ -197,9 +195,6 @@ # # Returns the available formats for dump-guest-memory # -# Returns: A @DumpGuestMemoryCapability object listing available -# formats for dump-guest-memory -# # Since: 2.0 # # Example: diff --git a/qapi/job.json b/qapi/job.json index b3957207a4..4f22edde56 100644 --- a/qapi/job.json +++ b/qapi/job.json @@ -269,8 +269,6 @@ # # Return information about jobs. # -# Returns: a list with a @JobInfo for each active job -# # Since: 3.0 ## { 'command': 'query-jobs', 'returns': ['JobInfo'] } diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 29e695aa06..4ef7ef7b43 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -380,8 +380,6 @@ # # Return a list of supported virtual CPU definitions # -# Returns: a list of CpuDefinitionInfo -# # Since: 1.2 ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], @@ -499,12 +497,12 @@ ## # @query-s390x-cpu-polarization: # +# Return the machine's CPU polarization. +# # Features: # # @unstable: This command is experimental. # -# Returns: the machine's CPU polarization -# # Since: 8.2 ## { 'command': 'query-s390x-cpu-polarization', 'returns': 'CpuPolarizationInfo', diff --git a/qapi/machine.json b/qapi/machine.json index bce6e1bbc4..b8f4c83914 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -100,8 +100,6 @@ # # Returns information about all virtual CPUs. # -# Returns: list of @CpuInfoFast -# # Since: 2.12 # # Example: @@ -217,8 +215,6 @@ # # @unstable: Argument @compat-props is experimental. # -# Returns: a list of MachineInfo -# # Since: 1.2 # # Example: @@ -267,8 +263,6 @@ # # Return information on the current virtual machine. # -# Returns: CurrentMachineParams -# # Since: 4.0 ## { 'command': 'query-current-machine', 'returns': 'CurrentMachineParams' } @@ -290,8 +284,6 @@ # # Return information about the target for this QEMU # -# Returns: TargetInfo -# # Since: 1.2 ## { 'command': 'query-target', 'returns': 'TargetInfo' } @@ -315,8 +307,6 @@ # # Query the guest UUID information. # -# Returns: The @UuidInfo for the guest -# # Since: 0.14 # # Example: @@ -468,8 +458,6 @@ # # Returns information about KVM acceleration # -# Returns: @KvmInfo -# # Since: 0.14 # # Example: @@ -924,8 +912,6 @@ # # Returns information for all memory backends. # -# Returns: a list of @Memdev. -# # Since: 2.1 # # Example: @@ -1042,8 +1028,6 @@ # # TODO: Better documentation; currently there is none. # -# Returns: a list of HotpluggableCPU objects. -# # Since: 2.7 # # Examples: @@ -1155,9 +1139,6 @@ # # Return information about the balloon device. # -# Returns: -# @BalloonInfo -# # Errors: # - If the balloon driver is enabled but not functional because # the KVM kernel module cannot support it, KVMMissingCap @@ -1221,9 +1202,6 @@ # Returns the hv-balloon driver data contained in the last received # "STATUS" message from the guest. # -# Returns: -# @HvBalloonInfo -# # Errors: # - If no hv-balloon device is present, guest memory status # reporting is not enabled or no guest memory status report @@ -1729,8 +1707,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: interrupt statistics -# # Since: 6.2 ## { 'command': 'x-query-irq', @@ -1746,8 +1722,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: TCG compiler statistics -# # Since: 6.2 ## { 'command': 'x-query-jit', @@ -1764,8 +1738,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: topology information -# # Since: 6.2 ## { 'command': 'x-query-numa', @@ -1781,8 +1753,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: TCG opcode counters -# # Since: 6.2 ## { 'command': 'x-query-opcount', @@ -1799,8 +1769,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: system ramblock information -# # Since: 6.2 ## { 'command': 'x-query-ramblock', @@ -1816,8 +1784,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: registered ROMs -# # Since: 6.2 ## { 'command': 'x-query-roms', @@ -1833,8 +1799,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: USB device information -# # Since: 6.2 ## { 'command': 'x-query-usb', diff --git a/qapi/migration.json b/qapi/migration.json index 8c65b90328..e22645253c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -305,8 +305,6 @@ # status and if block migration is active another one with block # migration status. # -# Returns: @MigrationInfo -# # Since: 0.14 # # Examples: @@ -597,8 +595,6 @@ # # Returns information about the current migration capabilities status # -# Returns: @MigrationCapabilityStatus -# # Since: 1.2 # # Example: @@ -1412,8 +1408,6 @@ # # Returns information about the current migration parameters # -# Returns: @MigrationParameters -# # Since: 2.4 # # Example: @@ -1997,8 +1991,6 @@ # # Query replication status while the vm is running. # -# Returns: A @ReplicationStatus object showing the status. -# # Example: # # -> { "execute": "query-xen-replication-status" } @@ -2051,8 +2043,6 @@ # # Query COLO status while the vm is running. # -# Returns: A @COLOStatus object showing the status. -# # Example: # # -> { "execute": "query-colo-status" } @@ -2419,8 +2409,6 @@ # # Returns information of migration threads # -# Returns: @MigrationThreadInfo -# # Since: 7.2 ## { 'command': 'query-migrationthreads', diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 4e0a6492a9..9edb7c1ade 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -85,8 +85,6 @@ # # Returns information about SEV # -# Returns: @SevInfo -# # Since: 2.12 # # Example: @@ -116,8 +114,6 @@ # # Query the SEV guest launch information. # -# Returns: The @SevLaunchMeasureInfo for the guest -# # Since: 2.12 # # Example: @@ -161,8 +157,6 @@ # This command is used to get the SEV capabilities, and is supported # on AMD X86 platforms only. # -# Returns: SevCapability objects. -# # Since: 2.12 # # Example: @@ -215,8 +209,6 @@ # @mnonce: a random 16 bytes value encoded in base64 (it will be # included in report) # -# Returns: SevAttestationReport objects. -# # Since: 6.1 # # Example: @@ -280,8 +272,6 @@ # This command is ARM-only. It will return a list of GICCapability # objects that describe its capability bits. # -# Returns: a list of GICCapability objects. -# # Since: 2.6 # # Example: @@ -338,8 +328,6 @@ # # Returns information about SGX # -# Returns: @SGXInfo -# # Since: 6.2 # # Example: @@ -357,8 +345,6 @@ # # Returns information from host SGX capabilities # -# Returns: @SGXInfo -# # Since: 6.2 # # Example: @@ -432,8 +418,6 @@ # # Query the Xen event channels opened by the guest. # -# Returns: list of open event channel ports. -# # Since: 8.0 # # Example: diff --git a/qapi/misc.json b/qapi/misc.json index ec30e5c570..ab2d234973 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -56,8 +56,6 @@ # # Return the name information of a guest. # -# Returns: @NameInfo of the guest -# # Since: 0.14 # # Example: @@ -101,14 +99,12 @@ ## # @query-iothreads: # -# Returns a list of information about each iothread. +# Returns information about each iothread. # # Note: this list excludes the QEMU main loop thread, which is not # declared using the -object iothread command-line option. It is # always the main thread of the process. # -# Returns: a list of @IOThreadInfo for each iothread -# # Since: 2.0 # # Example: @@ -331,9 +327,6 @@ # # @opaque: A free-form string that can be used to describe the fd. # -# Returns: -# @AddfdInfo -# # Errors: # - If file descriptor was not received, GenericError # - If @fdset-id is a negative value, GenericError @@ -415,8 +408,6 @@ # # Return information describing all fd sets. # -# Returns: A list of @FdsetInfo -# # Since: 1.2 # # Note: The list of fd sets is shared by all monitor connections. @@ -514,10 +505,7 @@ # # Query command line option schema. # -# @option: option name -# -# Returns: list of @CommandLineOptionInfo for all options (or for the -# given @option). +# @option: limit query to just @option # # Errors: # - if the given @option doesn't exist diff --git a/qapi/pci.json b/qapi/pci.json index 08bf695863..6355411373 100644 --- a/qapi/pci.json +++ b/qapi/pci.json @@ -178,7 +178,7 @@ # Returns: a list of @PciInfo for each PCI bus. Each bus is # represented by a json-object, which has a key with a json-array # of all PCI devices attached to it. Each device is represented -# by a json-object. +# by a json-object. TODO check # # Since: 0.14 # diff --git a/qapi/qdev.json b/qapi/qdev.json index facaa0bc6a..798dc831d5 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -17,9 +17,6 @@ # # @typename: the type name of a device # -# Returns: a list of ObjectPropertyInfo describing a devices -# properties -# # Note: objects can create properties at runtime, for example to # describe links between different devices and/or objects. These # properties are not included in the output of this command. diff --git a/qapi/qom.json b/qapi/qom.json index 38dde6d785..d1dc216474 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -54,9 +54,6 @@ # @path: the path within the object model. See @qom-get for a # description of this parameter. # -# Returns: a list of @ObjectPropertyInfo that describe the properties -# of the object. -# # Since: 1.2 # # Example: @@ -178,9 +175,6 @@ # # @abstract: if true, include abstract types in the results # -# Returns: a list of @ObjectTypeInfo or an empty list if no results -# are found -# # Since: 1.1 ## { 'command': 'qom-list-types', @@ -199,8 +193,6 @@ # describe links between different devices and/or objects. These # properties are not included in the output of this command. # -# Returns: a list of ObjectPropertyInfo describing object properties -# # Since: 2.12 ## { 'command': 'qom-list-properties', diff --git a/qapi/replay.json b/qapi/replay.json index d3559f9c8f..e66823bf03 100644 --- a/qapi/replay.json +++ b/qapi/replay.json @@ -50,8 +50,6 @@ # instruction count which may be used for @replay-break and # @replay-seek commands. # -# Returns: record/replay information. -# # Since: 5.2 # # Example: diff --git a/qapi/rocker.json b/qapi/rocker.json index 5635cf174f..03c42713b4 100644 --- a/qapi/rocker.json +++ b/qapi/rocker.json @@ -26,8 +26,6 @@ # # Return rocker switch information. # -# Returns: @Rocker information -# # Since: 2.4 # # Example: @@ -94,8 +92,6 @@ # # Return rocker switch port information. # -# Returns: a list of @RockerPort information -# # Since: 2.4 # # Example: @@ -236,8 +232,6 @@ # @tbl-id: flow table ID. If tbl-id is not specified, returns flow # information for all tables. # -# Returns: rocker OF-DPA flow information -# # Since: 2.4 # # Example: @@ -311,8 +305,6 @@ # @type: group type. If type is not specified, returns group # information for all group types. # -# Returns: rocker OF-DPA group information -# # Since: 2.4 # # Example: diff --git a/qapi/run-state.json b/qapi/run-state.json index f8773f23b2..37c30ee3a2 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -119,8 +119,6 @@ # # Query the run status of the VM # -# Returns: @StatusInfo reflecting the VM -# # Since: 0.14 # # Example: diff --git a/qapi/stats.json b/qapi/stats.json index 578b52c7ef..0753c11aa2 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -187,7 +187,7 @@ # to return statistics about. # # Returns: a list of StatsResult, one for each provider and object -# (e.g., for each vCPU). +# (e.g., for each vCPU). TODO check # # Since: 7.1 ## diff --git a/qapi/tpm.json b/qapi/tpm.json index 1577b5c259..6002a17f0e 100644 --- a/qapi/tpm.json +++ b/qapi/tpm.json @@ -27,8 +27,6 @@ # # Return a list of supported TPM models # -# Returns: a list of TpmModel -# # Since: 1.5 # # Example: @@ -58,8 +56,6 @@ # # Return a list of supported TPM types # -# Returns: a list of TpmType -# # Since: 1.5 # # Example: diff --git a/qapi/trace.json b/qapi/trace.json index 043d12f83e..27a98fc9d9 100644 --- a/qapi/trace.json +++ b/qapi/trace.json @@ -52,7 +52,8 @@ # # Query the state of events. # -# @name: Event name pattern (case-sensitive glob). +# @name: Limit the query to events with a name matching @name +# (case-sensitive glob). # # @vcpu: The vCPU to query (since 2.7). # @@ -60,8 +61,6 @@ # # @deprecated: Member @vcpu is deprecated, and always ignored. # -# Returns: a list of @TraceEventInfo for the matching events -# # Since: 2.2 # # Example: diff --git a/qapi/ui.json b/qapi/ui.json index f610bce118..2b7f0b8401 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -327,8 +327,6 @@ # # Returns information about the current SPICE server # -# Returns: @SpiceInfo -# # Since: 0.14 # # Example: @@ -658,8 +656,6 @@ # # Returns information about the current VNC server # -# Returns: @VncInfo -# # Since: 0.14 # # Example: @@ -689,8 +685,6 @@ # # Returns a list of vnc servers. The list can be empty. # -# Returns: a list of @VncInfo2 -# # Since: 2.3 ## { 'command': 'query-vnc-servers', 'returns': ['VncInfo2'], @@ -824,8 +818,6 @@ # # Returns information about each active mouse device # -# Returns: a list of @MouseInfo for each device -# # Since: 0.14 # # Example: @@ -1564,8 +1556,6 @@ # # Returns information about display configuration # -# Returns: @DisplayOptions -# # Since: 3.1 ## { 'command': 'query-display-options', diff --git a/qapi/virtio.json b/qapi/virtio.json index 74fc27c702..476a2a4192 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -30,8 +30,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: List of gathered VirtIODevices -# # Since: 7.2 # # Example: @@ -199,8 +197,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: VirtioStatus of the virtio device -# # Since: 7.2 # # Examples: @@ -557,8 +553,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: VirtQueueStatus of the VirtQueue -# # Notes: last_avail_idx will not be displayed in the case where the # selected VirtIODevice has a running vhost device and the # VirtIODevice VirtQueue index (queue) does not exist for the @@ -686,8 +680,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: VirtVhostQueueStatus of the vhost_virtqueue -# # Since: 7.2 # # Examples: @@ -835,8 +827,6 @@ # # @unstable: This command is meant for debugging. # -# Returns: VirtioQueueElement information -# # Since: 7.2 # # Examples: diff --git a/qapi/yank.json b/qapi/yank.json index 89f2f4d199..82e3515308 100644 --- a/qapi/yank.json +++ b/qapi/yank.json @@ -102,8 +102,6 @@ # # Query yank instances. See @YankInstance for more information. # -# Returns: list of @YankInstance -# # Example: # # -> { "execute": "query-yank" } From patchwork Mon May 6 11:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E798CC25B5C for ; Mon, 6 May 2024 11:04:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7p-00034P-2X; Mon, 06 May 2024 07:03:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7h-0002p0-4J for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7Z-0003fS-Ts for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993380; 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=OA65odhw6yvz8wFdh9oVTxjcsGiEwAHIVPPzhH06qI0=; b=Jm6Qc6KjVIjalf9TtU8zyzurHAhioN1zNy7naFp3zKYjr5HhHKWXds75X6Y2y8xHRurMMJ vg7xt/S5UZh0DXtXD6xKrlLzZaXl9mttGuyo84o1byYIX7Z1XZ5pa0jDTle7He80DJmTW3 hS/mKfC4d985axPy+bNtPGwd5ocw0Cw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-FojZnOdKPZaK3ZQ-ze9Dag-1; Mon, 06 May 2024 07:02:56 -0400 X-MC-Unique: FojZnOdKPZaK3ZQ-ze9Dag-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91CB329AA3AF; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 580266958; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 55CDA21D49C0; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PULL 6/7] qapi: Move conditional code from QAPISchemaVariants to its subtypes Date: Mon, 6 May 2024 13:02:51 +0200 Message-ID: <20240506110254.3965097-12-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org QAPISchemaVariants.check()'s code is almost entirely conditional on union vs. alternate type. Move the conditional code to QAPISchemaBranches.check() and QAPISchemaAlternatives.check(), where the conditions are always satisfied. Attribute QAPISchemaVariants.tag_name is now only used by QAPISchemaBranches. Move it there. Refactor the three types' .__init__() to make them a bit simpler. Signed-off-by: Markus Armbruster --- scripts/qapi/schema.py | 138 ++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 9bdbfd52b2..c5b824f1fd 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -719,20 +719,11 @@ def visit(self, visitor: QAPISchemaVisitor) -> None: class QAPISchemaVariants: def __init__( self, - tag_name: Optional[str], info: QAPISourceInfo, - tag_member: Optional[QAPISchemaObjectTypeMember], variants: List[QAPISchemaVariant], ): - # Unions pass tag_name but not tag_member. - # Alternates pass tag_member but not tag_name. - # After check(), tag_member is always set. - assert bool(tag_member) != bool(tag_name) - assert (isinstance(tag_name, str) or - isinstance(tag_member, QAPISchemaObjectTypeMember)) - self._tag_name = tag_name self.info = info - self._tag_member = tag_member + self._tag_member: Optional[QAPISchemaObjectTypeMember] = None self.variants = variants @property @@ -749,58 +740,66 @@ def set_defined_in(self, name: str) -> None: v.set_defined_in(name) def check( - self, schema: QAPISchema, seen: Dict[str, QAPISchemaMember] + self, schema: QAPISchema, seen: Dict[str, QAPISchemaMember] ) -> None: - if self._tag_name: # union - # We need to narrow the member type: - tmp = seen.get(c_name(self._tag_name)) - assert tmp is None or isinstance(tmp, QAPISchemaObjectTypeMember) - self._tag_member = tmp + for v in self.variants: + v.check(schema) - base = "'base'" - # Pointing to the base type when not implicit would be - # nice, but we don't know it here - if not self._tag_member or self._tag_name != self._tag_member.name: - raise QAPISemError( - self.info, - "discriminator '%s' is not a member of %s" - % (self._tag_name, base)) - # Here we do: - assert self.tag_member.defined_in - base_type = schema.lookup_type(self.tag_member.defined_in) - assert base_type - if not base_type.is_implicit(): - base = "base type '%s'" % self.tag_member.defined_in - if not isinstance(self.tag_member.type, QAPISchemaEnumType): - raise QAPISemError( - self.info, - "discriminator member '%s' of %s must be of enum type" - % (self._tag_name, base)) - if self.tag_member.optional: - raise QAPISemError( - self.info, - "discriminator member '%s' of %s must not be optional" - % (self._tag_name, base)) - if self.tag_member.ifcond.is_present(): - raise QAPISemError( - self.info, - "discriminator member '%s' of %s must not be conditional" - % (self._tag_name, base)) - else: # alternate - assert self._tag_member - assert isinstance(self.tag_member.type, QAPISchemaEnumType) - assert not self.tag_member.optional - assert not self.tag_member.ifcond.is_present() - if self._tag_name: # union - # branches that are not explicitly covered get an empty type - assert self.tag_member.defined_in - cases = {v.name for v in self.variants} - for m in self.tag_member.type.members: - if m.name not in cases: - v = QAPISchemaVariant(m.name, self.info, - 'q_empty', m.ifcond) - v.set_defined_in(self.tag_member.defined_in) - self.variants.append(v) + +class QAPISchemaBranches(QAPISchemaVariants): + def __init__(self, + info: QAPISourceInfo, + variants: List[QAPISchemaVariant], + tag_name: str): + super().__init__(info, variants) + self._tag_name = tag_name + + def check( + self, schema: QAPISchema, seen: Dict[str, QAPISchemaMember] + ) -> None: + # We need to narrow the member type: + tmp = seen.get(c_name(self._tag_name)) + assert tmp is None or isinstance(tmp, QAPISchemaObjectTypeMember) + self._tag_member = tmp + + base = "'base'" + # Pointing to the base type when not implicit would be + # nice, but we don't know it here + if not self._tag_member or self._tag_name != self._tag_member.name: + raise QAPISemError( + self.info, + "discriminator '%s' is not a member of %s" + % (self._tag_name, base)) + # Here we do: + assert self.tag_member.defined_in + base_type = schema.lookup_type(self.tag_member.defined_in) + assert base_type + if not base_type.is_implicit(): + base = "base type '%s'" % self.tag_member.defined_in + if not isinstance(self.tag_member.type, QAPISchemaEnumType): + raise QAPISemError( + self.info, + "discriminator member '%s' of %s must be of enum type" + % (self._tag_name, base)) + if self.tag_member.optional: + raise QAPISemError( + self.info, + "discriminator member '%s' of %s must not be optional" + % (self._tag_name, base)) + if self.tag_member.ifcond.is_present(): + raise QAPISemError( + self.info, + "discriminator member '%s' of %s must not be conditional" + % (self._tag_name, base)) + # branches that are not explicitly covered get an empty type + assert self.tag_member.defined_in + cases = {v.name for v in self.variants} + for m in self.tag_member.type.members: + if m.name not in cases: + v = QAPISchemaVariant(m.name, self.info, + 'q_empty', m.ifcond) + v.set_defined_in(self.tag_member.defined_in) + self.variants.append(v) if not self.variants: raise QAPISemError(self.info, "union has no branches") for v in self.variants: @@ -834,20 +833,21 @@ def check_clash( v.type.check_clash(info, dict(seen)) -class QAPISchemaBranches(QAPISchemaVariants): - def __init__(self, - info: QAPISourceInfo, - variants: List[QAPISchemaVariant], - tag_name: str): - super().__init__(tag_name, info, None, variants) - - class QAPISchemaAlternatives(QAPISchemaVariants): def __init__(self, info: QAPISourceInfo, variants: List[QAPISchemaVariant], tag_member: QAPISchemaObjectTypeMember): - super().__init__(None, info, tag_member, variants) + super().__init__(info, variants) + self._tag_member = tag_member + + def check( + self, schema: QAPISchema, seen: Dict[str, QAPISchemaMember] + ) -> None: + super().check(schema, seen) + assert isinstance(self.tag_member.type, QAPISchemaEnumType) + assert not self.tag_member.optional + assert not self.tag_member.ifcond.is_present() class QAPISchemaMember: From patchwork Mon May 6 11:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13655320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04969C10F16 for ; Mon, 6 May 2024 11:06:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3w7o-00032N-9J; Mon, 06 May 2024 07:03:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7a-0002lM-TI for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3w7X-0003ek-3n for qemu-devel@nongnu.org; Mon, 06 May 2024 07:03:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714993378; 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=t0bAfLx0fSN9+pKtZd6qempTW+VtaN8OzkHnNuAO3EY=; b=F6hOfpSODIoshj02oXdrpGkM6wo5lvyO9zPuL25kM6fkkxQR6QUXdZuf3j8zqomfWaS/mY NiQb3bT9e2RgCyzCr/FmhQkCgXXc1LAv2KFx/HUxmhoiDNV3K0/EXkFsb4HTyFCdUDMhbN sbai6hU0zequY8qgBiP0/uaUVV3mZKA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-YlVr0dCRNsiZ9_hajyr2WA-1; Mon, 06 May 2024 07:02:57 -0400 X-MC-Unique: YlVr0dCRNsiZ9_hajyr2WA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9767E38000AF; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D53D200B2C4; Mon, 6 May 2024 11:02:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5B32921D49C4; Mon, 6 May 2024 13:02:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 7/7] find untagged sections WIP Date: Mon, 6 May 2024 13:02:53 +0200 Message-ID: <20240506110254.3965097-14-armbru@redhat.com> In-Reply-To: <20240506110254.3965097-1-armbru@redhat.com> References: <20240506110254.3965097-1-armbru@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --- qapi/block-core.json | 1 + qapi/introspect.json | 4 ++++ qapi/machine-target.json | 2 ++ qapi/migration.json | 3 +++ qapi/net.json | 2 ++ qapi/qom.json | 1 + qapi/ui.json | 1 + qga/qapi-schema.json | 2 ++ scripts/qapi/parser.py | 1 + tests/qapi-schema/doc-good.out | 1 + 10 files changed, 18 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index fab1a45365..1c43d3d2bb 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3289,6 +3289,7 @@ # # @namespace: namespace number of the device, starting from 1. # +# @@@ untagged # Note that the PCI @device must have been unbound from any host # kernel driver before instructing QEMU to add the blockdev. # diff --git a/qapi/introspect.json b/qapi/introspect.json index b041b02ba8..1747562a41 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -149,6 +149,7 @@ # # @deprecated: Member @values is deprecated. Use @members instead. # +# @@@ untagged # Values of this type are JSON string on the wire. # # Since: 2.5 @@ -180,6 +181,7 @@ # # @element-type: the array type's element type. # +# @@@ untagged # Values of this type are JSON array on the wire. # # Since: 2.5 @@ -203,6 +205,7 @@ # The variants are in no particular order, and may even differ # from the order of the values of the enum type of the @tag. # +# @@@ untagged # Values of this type are JSON object on the wire. # # Since: 2.5 @@ -261,6 +264,7 @@ # members' wire encoding is distinct, see # :doc:`/devel/qapi-code-gen` section Alternate types. # +# @@@ untagged # On the wire, this can be any of the members. # # Since: 2.5 diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 4ef7ef7b43..37ffd6409b 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -107,6 +107,7 @@ # @responsible-properties: List of properties that led to the # comparison result not being identical. # +# @@@ untagged # @responsible-properties is a list of QOM property names that led to # both CPUs not being detected as identical. For identical models, # this list is empty. If a QOM property is read-only, that means @@ -342,6 +343,7 @@ # removed in in some future version of QEMU according to the QEMU # deprecation policy. (since 5.2) # +# @@@ untagged # @unavailable-features is a list of QOM property names that represent # CPU model attributes that prevent the CPU from running. If the QOM # property is read-only, that means there's no known way to make the diff --git a/qapi/migration.json b/qapi/migration.json index e22645253c..97a727c41a 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -2427,6 +2427,7 @@ # # @devices: list of block device node names to save a snapshot to # +# @@@ untagged # Applications should not assume that the snapshot save is complete # when this command returns. The job commands / events must be used # to determine completion and to fetch details of any errors that @@ -2499,6 +2500,7 @@ # # @devices: list of block device node names to load a snapshot from # +# @@@ untagged # Applications should not assume that the snapshot load is complete # when this command returns. The job commands / events must be used # to determine completion and to fetch details of any errors that @@ -2567,6 +2569,7 @@ # # @devices: list of block device node names to delete a snapshot from # +# @@@ untagged # Applications should not assume that the snapshot delete is complete # when this command returns. The job commands / events must be used # to determine completion and to fetch details of any errors that diff --git a/qapi/net.json b/qapi/net.json index 0f5a259475..da21c02fa2 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -650,6 +650,7 @@ # attempt a reconnect after the given number of seconds. Setting # this to zero disables this function. (default: 0) (since 8.0) # +# @@@ untagged # Only SocketAddress types 'unix', 'inet' and 'fd' are supported. # # Since: 7.2 @@ -669,6 +670,7 @@ # # @local: local address # +# @@@ untagged # Only SocketAddress types 'unix', 'inet' and 'fd' are supported. # # If remote address is present and it's a multicast address, local diff --git a/qapi/qom.json b/qapi/qom.json index d1dc216474..237711cd59 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -547,6 +547,7 @@ # algorithm detects it is spending too long polling without # encountering events. 0 selects a default behaviour (default: 0) # +# @@@ untagged # The @aio-max-batch option is available since 6.1. # # Since: 2.0 diff --git a/qapi/ui.json b/qapi/ui.json index 2b7f0b8401..b2c3f143dc 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -934,6 +934,7 @@ # # @f24: since 8.0 # +# @@@ untagged # 'sysrq' was mistakenly added to hack around the fact that the ps2 # driver was not generating correct scancodes sequences when # 'alt+print' was pressed. This flaw is now fixed and the 'sysrq' key diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index fe41670ed2..17cdb52f83 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -207,6 +207,7 @@ # # @mode: "halt", "powerdown" (default), or "reboot" # +# @@@ untagged # This command does NOT return a response on success. Success # condition is indicated by the VM exiting with a zero exit status or, # when running with --no-shutdown, by issuing the query-status QMP @@ -1050,6 +1051,7 @@ # # @crypted: true if password is already crypt()d, false if raw # +# @@@ untagged # If the @crypted flag is true, it is the caller's responsibility to # ensure the correct crypt() encryption scheme is used. This command # does not attempt to interpret or report on the encryption scheme. diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index e8a482c37d..126acab38d 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -665,6 +665,7 @@ def ensure_untagged_section(self, info: QAPISourceInfo) -> None: section = self.Section(info) self.sections.append(section) self.all_sections.append(section) + section.append_line(f'### untagged {info.loc()}') def new_tagged_section(self, info: QAPISourceInfo, tag: str) -> None: section = self.Section(info, tag) diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index f2be711a2c..067e3d1135 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -112,6 +112,7 @@ Also _one_ {and only} feature=enum-member-feat a member feature section=None +### untagged /work/armbru/qemu/bld/../tests/qapi-schema/doc-good.json:67 @two is undocumented doc symbol=Base body=