From nobody Thu Apr 25 05:20:35 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 1631538325658516.7710692468263; Mon, 13 Sep 2021 06:05:25 -0700 (PDT) Received: from localhost ([::1]:43682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPleG-0002or-Fi for importer@patchew.org; Mon, 13 Sep 2021 09:05:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFb-0000SX-BM for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFV-0000j6-19 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-56-8aBYSZZONA-r-xX82viTJA-1; Mon, 13 Sep 2021 08:39:44 -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 84B0B19200CD for ; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 769026A8E4; Mon, 13 Sep 2021 12:39:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0EC60113861E; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536785; 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=OHYrqMNj1mc7wsV4zsrYzX2l7bJurtSgTSwsoB4r2Do=; b=Npvg/mAi22Dcv2CD2SUWCCuFx7N2Cq9KjrT5SCu/0lx/qUta84+YU/H7gfh9+rf5epkihi /s7BLh687IJwGP2tQxVpmIlUtox7DalMkCLUhhRXas2IRhHjR1uZi82xhyIpmtOqa6CJ8n 66sry06IWAe8t+f5i/clEy/yo0Q9euw= X-MC-Unique: 8aBYSZZONA-r-xX82viTJA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 01/22] qapi: Tidy up unusual line breaks Date: Mon, 13 Sep 2021 14:39:11 +0200 Message-Id: <20210913123932.3306639-2-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631538357174100001 Content-Type: text/plain; charset="utf-8" Break lines between members instead of within members. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- docs/devel/qapi-code-gen.rst | 12 +++++------ tests/qapi-schema/doc-good.json | 4 ++-- tests/qapi-schema/enum-if-invalid.json | 4 ++-- tests/qapi-schema/qapi-schema-test.json | 28 ++++++++++++------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index ced7a5ffe1..b154eae82e 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -859,9 +859,9 @@ longhand form of MEMBER. Example: a struct type with unconditional member 'foo' and conditional member 'bar' :: =20 - { 'struct': 'IfStruct', 'data': - { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'IFCOND'} } } + { 'struct': 'IfStruct', + 'data': { 'foo': 'int', + 'bar': { 'type': 'int', 'if': 'IFCOND'} } } =20 A union's discriminator may not be conditional. =20 @@ -871,9 +871,9 @@ the longhand form of ENUM-VALUE_. Example: an enum type with unconditional value 'foo' and conditional value 'bar' :: =20 - { 'enum': 'IfEnum', 'data': - [ 'foo', - { 'name' : 'bar', 'if': 'IFCOND' } ] } + { 'enum': 'IfEnum', + 'data': [ 'foo', + { 'name' : 'bar', 'if': 'IFCOND' } ] } =20 Likewise, features can be conditional. This requires the longhand form of FEATURE_. diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index e0027e4cf6..cbf5c56c4b 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -60,8 +60,8 @@ # # @two is undocumented ## -{ 'enum': 'Enum', 'data': - [ { 'name': 'one', 'if': 'IFONE' }, 'two' ], +{ 'enum': 'Enum', + 'data': [ { 'name': 'one', 'if': 'IFONE' }, 'two' ], 'features': [ 'enum-feat' ], 'if': 'IFCOND' } =20 diff --git a/tests/qapi-schema/enum-if-invalid.json b/tests/qapi-schema/enu= m-if-invalid.json index 60bd0ef1d7..6bd20041f3 100644 --- a/tests/qapi-schema/enum-if-invalid.json +++ b/tests/qapi-schema/enum-if-invalid.json @@ -1,3 +1,3 @@ # check invalid 'if' type -{ 'enum': 'TestIfEnum', 'data': - [ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] } +{ 'enum': 'TestIfEnum', + 'data': [ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index b6c36a9eee..3c43e14e22 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -220,27 +220,27 @@ =20 # test 'if' condition handling =20 -{ 'struct': 'TestIfStruct', 'data': - { 'foo': 'int', - 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} }, +{ 'struct': 'TestIfStruct', + 'data': { 'foo': 'int', + 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} }, 'if': 'TEST_IF_STRUCT' } =20 -{ 'enum': 'TestIfEnum', 'data': - [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], +{ 'enum': 'TestIfEnum', + 'data': [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ], 'if': 'TEST_IF_ENUM' } =20 -{ 'union': 'TestIfUnion', 'data': - { 'foo': 'TestStruct', - 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, +{ 'union': 'TestIfUnion', + 'data': { 'foo': 'TestStruct', + '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': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 -{ 'alternate': 'TestIfAlternate', 'data': - { 'foo': 'int', - 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} }, +{ 'alternate': 'TestIfAlternate', + 'data': { 'foo': 'int', + 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} }, 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-alternate-cmd', @@ -256,9 +256,9 @@ =20 { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } =20 -{ 'event': 'TEST_IF_EVENT', 'data': - { 'foo': 'TestIfStruct', - 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, +{ 'event': 'TEST_IF_EVENT', + 'data': { 'foo': 'TestIfStruct', + 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } } =20 { 'event': 'TEST_IF_EVENT2', 'data': {}, --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 163153726397686.35721864878747; Mon, 13 Sep 2021 05:47:43 -0700 (PDT) Received: from localhost ([::1]:36842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlN7-0003Kf-94 for importer@patchew.org; Mon, 13 Sep 2021 08:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFP-0000DW-Du for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFL-0000br-FF for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-193-QNJk1FvZMA2QegQwi2VVIA-1; Mon, 13 Sep 2021 08:39:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86DA8835DE0 for ; Mon, 13 Sep 2021 12:39:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7671060C9D; Mon, 13 Sep 2021 12:39:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 11B0C11385C1; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536778; 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=p1rLJePcd7ysNK6oxxOJut+V5DP8wpfsSzAZXrNxJ+E=; b=XUXnrC2KfjRXXigT8jeEgDvyy9iL/6QwiS2pB91JEV2gpPLBhlGZ9N2TIjLBgCDFeRfySz YEWhi4EWkXOuGVjJZpFk6NaYd5HdFDb/3aCsCuQUTZLRQUuc/Tknq4QnDwJUfKBOUe7kzR ER9BhiBkS/J1UxiS6ctcBW4P5ShWH0k= X-MC-Unique: QNJk1FvZMA2QegQwi2VVIA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/22] qapi: Stop enforcing "type name should not end in 'Kind' Date: Mon, 13 Sep 2021 14:39:12 +0200 Message-Id: <20210913123932.3306639-3-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631537265408100001 Content-Type: text/plain; charset="utf-8" I'm about to convert simple unions to flat unions, then drop simple union support. The conversion involves making the implict enum types explicit. To reduce churn, I'd like to name them exactly like the implicit types they replace. However, these names are reserved for the generator's use. They won't be once simple unions are gone. Stop enforcing this naming rule now rather than then. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 6 +++--- tests/qapi-schema/meson.build | 1 - tests/qapi-schema/reserved-type-kind.err | 2 -- tests/qapi-schema/reserved-type-kind.json | 2 -- tests/qapi-schema/reserved-type-kind.out | 0 5 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 tests/qapi-schema/reserved-type-kind.err delete mode 100644 tests/qapi-schema/reserved-type-kind.json delete mode 100644 tests/qapi-schema/reserved-type-kind.out diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 90bde501b0..91959ee79a 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -171,7 +171,7 @@ def check_defn_name_str(name: str, info: QAPISourceInfo= , meta: str) -> None: - 'event' names adhere to `check_name_upper()`. - 'command' names adhere to `check_name_lower()`. - Else, meta is a type, and must pass `check_name_camel()`. - These names must not end with ``Kind`` nor ``List``. + These names must not end with ``List``. =20 :param name: Name to check. :param info: QAPI schema source file information. @@ -187,9 +187,9 @@ def check_defn_name_str(name: str, info: QAPISourceInfo= , meta: str) -> None: permit_underscore=3Dname in info.pragma.command_name_exception= s) else: check_name_camel(name, info, meta) - if name.endswith('Kind') or name.endswith('List'): + if name.endswith('List'): raise QAPISemError( - info, "%s name should not end in '%s'" % (meta, name[-4:])) + info, "%s name should not end in 'List'" % meta) =20 =20 def check_keys(value: _JSONObject, diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 6b2a4ce41a..0798e94042 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -168,7 +168,6 @@ schemas =3D [ 'reserved-member-q.json', 'reserved-member-u.json', 'reserved-member-underscore.json', - 'reserved-type-kind.json', 'reserved-type-list.json', 'returns-alternate.json', 'returns-array-bad.json', diff --git a/tests/qapi-schema/reserved-type-kind.err b/tests/qapi-schema/r= eserved-type-kind.err deleted file mode 100644 index d8fb769f9d..0000000000 --- a/tests/qapi-schema/reserved-type-kind.err +++ /dev/null @@ -1,2 +0,0 @@ -reserved-type-kind.json: In enum 'UnionKind': -reserved-type-kind.json:2: enum name should not end in 'Kind' diff --git a/tests/qapi-schema/reserved-type-kind.json b/tests/qapi-schema/= reserved-type-kind.json deleted file mode 100644 index 9ecaba12bc..0000000000 --- a/tests/qapi-schema/reserved-type-kind.json +++ /dev/null @@ -1,2 +0,0 @@ -# we reject types that would conflict with implicit union enum -{ 'enum': 'UnionKind', 'data': [ 'oops' ] } diff --git a/tests/qapi-schema/reserved-type-kind.out b/tests/qapi-schema/r= eserved-type-kind.out deleted file mode 100644 index e69de29bb2..0000000000 --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631538592791522.3581921287621; Mon, 13 Sep 2021 06:09:52 -0700 (PDT) Received: from localhost ([::1]:53604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPliZ-0001AH-Kn for importer@patchew.org; Mon, 13 Sep 2021 09:09:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFZ-0000PS-Hg for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000iU-Up for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-247-zYL47QlhOIC5cP8pz52Ydg-1; Mon, 13 Sep 2021 08:39:43 -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 AA3FF80196C for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8356C5D9CA; Mon, 13 Sep 2021 12:39:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 150E311385C3; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=X4hsfKp02H0aj06kz/JN9TMHhNShSOymGwtwfN2378Q=; b=blGODLXZoFS+CarqE1MpbqhOTKjTLcoc8Bxy2Asy+hTdYgN5BegLYtl4+NxONw6wEWMkaO Kl6mSPkVlmbSYWpU/AJaRorOA9zRWaCv855PxcVH2bHfTWdew8V97Toutb9+z4ycmrOTfy PrNleeE8hvSNm0E6ObJidODapwaXAbI= X-MC-Unique: zYL47QlhOIC5cP8pz52Ydg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 03/22] qapi: Convert simple union KeyValue to flat one Date: Mon, 13 Sep 2021 14:39:13 +0200 Message-Id: <20210913123932.3306639-4-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, Gerd Hoffmann , marcandre.lureau@redhat.com 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: 1631538593649100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union KeyValue to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Acked-by: Gerd Hoffmann Reviewed-by: Eric Blake --- qapi/ui.json | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index b2cf7a6759..a6b0dce876 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -824,6 +824,30 @@ 'ac_home', 'ac_back', 'ac_forward', 'ac_refresh', 'ac_bookmark= s', 'lang1', 'lang2' ] } =20 +## +# @KeyValueKind: +# +# Since: 6.1 +## +{ 'enum': 'KeyValueKind', + 'data': [ 'number', 'qcode' ] } + +## +# @IntWrapper: +# +# Since: 6.1 +## +{ 'struct': 'IntWrapper', + 'data': { 'data': 'int' } } + +## +# @QKeyCodeWrapper: +# +# Since: 6.1 +## +{ 'struct': 'QKeyCodeWrapper', + 'data': { 'data': 'QKeyCode' } } + ## # @KeyValue: # @@ -832,9 +856,11 @@ # Since: 1.3 ## { 'union': 'KeyValue', + 'base': { 'type': 'KeyValueKind' }, + 'discriminator': 'type', 'data': { - 'number': 'int', - 'qcode': 'QKeyCode' } } + 'number': 'IntWrapper', + 'qcode': 'QKeyCodeWrapper' } } =20 ## # @send-key: --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539169244127.54557854500797; Mon, 13 Sep 2021 06:19:29 -0700 (PDT) Received: from localhost ([::1]:44968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlrr-0006T3-SD for importer@patchew.org; Mon, 13 Sep 2021 09:19:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFV-0000HF-UA for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFP-0000gV-QD for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:49 -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-410-HXWr_DzeNae0e9KUCy7RjQ-1; Mon, 13 Sep 2021 08:39:42 -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 8271819200C0 for ; Mon, 13 Sep 2021 12:39:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 835B45C25A; Mon, 13 Sep 2021 12:39:33 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 186361138526; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536783; 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=dUjvvHUOALsBjzM+6DLoOne/rxeDCc8KkvTAsYVKpnE=; b=XKDUFa1xhU+5y4HUKNxGe4XorTglSnkxh4vflCmsV0+tlBtNQ6VUJsCKzUHv7mfaYRjdIO fS68ZhRkUdi+60RHxAc1iF5QIcgBRZI+32bOKXg3znAbMRhmpXUGtLq2n+EwKpqxlHjOW3 oQzPujxXXEZpiLJv74JGBGkSSnaDs8U= X-MC-Unique: HXWr_DzeNae0e9KUCy7RjQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 04/22] qapi: Convert simple union InputEvent to flat one Date: Mon, 13 Sep 2021 14:39:14 +0200 Message-Id: <20210913123932.3306639-5-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, Gerd Hoffmann , marcandre.lureau@redhat.com 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: 1631539170452100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union InputEvent to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Acked-by: Gerd Hoffmann Reviewed-by: Eric Blake --- qapi/ui.json | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index a6b0dce876..fe10d69431 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -960,6 +960,38 @@ 'data' : { 'axis' : 'InputAxis', 'value' : 'int' } } =20 +## +# @InputEventKind: +# +# Since: 6.1 +## +{ 'enum': 'InputEventKind', + 'data': [ 'key', 'btn', 'rel', 'abs' ] } + +## +# @InputKeyEventWrapper: +# +# Since: 6.1 +## +{ 'struct': 'InputKeyEventWrapper', + 'data': { 'data': 'InputKeyEvent' } } + +## +# @InputBtnEventWrapper: +# +# Since: 6.1 +## +{ 'struct': 'InputBtnEventWrapper', + 'data': { 'data': 'InputBtnEvent' } } + +## +# @InputMoveEventWrapper: +# +# Since: 6.1 +## +{ 'struct': 'InputMoveEventWrapper', + 'data': { 'data': 'InputMoveEvent' } } + ## # @InputEvent: # @@ -975,10 +1007,12 @@ # Since: 2.0 ## { 'union' : 'InputEvent', - 'data' : { 'key' : 'InputKeyEvent', - 'btn' : 'InputBtnEvent', - 'rel' : 'InputMoveEvent', - 'abs' : 'InputMoveEvent' } } + 'base': { 'type': 'InputEventKind' }, + 'discriminator': 'type', + 'data' : { 'key' : 'InputKeyEventWrapper', + 'btn' : 'InputBtnEventWrapper', + 'rel' : 'InputMoveEventWrapper', + 'abs' : 'InputMoveEventWrapper' } } =20 ## # @input-send-event: --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631538866016838.2226678370763; Mon, 13 Sep 2021 06:14:26 -0700 (PDT) Received: from localhost ([::1]:36238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlmy-0000C0-SC for importer@patchew.org; Mon, 13 Sep 2021 09:14:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFR-0000EV-Rv for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFP-0000ec-1N for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-579-FPi9SC2DN4W0W1rn-C49rA-1; Mon, 13 Sep 2021 08:39:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 207831018722; Mon, 13 Sep 2021 12:39:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF5DE60CC9; Mon, 13 Sep 2021 12:39:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1BB1D1138529; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536781; 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=GE21MWchKAKyY3X8bA98WuOECsHZ9lMgAEqip7yZf/c=; b=FxAQiehxaNwLhfxlwHJ4dzUGCUwZyFcMKZjw4iugcGHNH8IwKYvTNzWiTj72b9ldz8gsjA G9DbbRbaW3j9+SldN+Dy6aUIVZCMDWyc+cLtLsyVNuEjuOrM71YOkXlOSiashVFzHuoajI vAHefPoUUt03Px/Y/wBxZG72SpLnJYU= X-MC-Unique: FPi9SC2DN4W0W1rn-C49rA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/22] qapi: Convert simple union TpmTypeOptions to flat one Date: Mon, 13 Sep 2021 14:39:15 +0200 Message-Id: <20210913123932.3306639-6-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, Stefan Berger , eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631538866861100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union TpmTypeOptions to an equivalent flat one, with existing enum TpmType replacing implicit enum TpmTypeOptionsKind. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Stefan Berger Signed-off-by: Markus Armbruster Acked-by: Stefan Berger --- qapi/tpm.json | 24 ++++++++++++++++++++++-- backends/tpm/tpm_emulator.c | 2 +- backends/tpm/tpm_passthrough.c | 2 +- monitor/hmp-cmds.c | 8 ++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/qapi/tpm.json b/qapi/tpm.json index f4dde2f646..b3ade008bf 100644 --- a/qapi/tpm.json +++ b/qapi/tpm.json @@ -99,6 +99,24 @@ { 'struct': 'TPMEmulatorOptions', 'data': { 'chardev' : 'str' }, 'if': 'CONFIG_TPM' } =20 +## +# @TPMPassthroughOptionsWrapper: +# +# Since: 6.1 +## +{ 'struct': 'TPMPassthroughOptionsWrapper', + 'data': { 'data': 'TPMPassthroughOptions' }, + 'if': 'CONFIG_TPM' } + +## +# @TPMEmulatorOptionsWrapper: +# +# Since: 6.1 +## +{ 'struct': 'TPMEmulatorOptionsWrapper', + 'data': { 'data': 'TPMEmulatorOptions' }, + 'if': 'CONFIG_TPM' } + ## # @TpmTypeOptions: # @@ -110,8 +128,10 @@ # Since: 1.5 ## { 'union': 'TpmTypeOptions', - 'data': { 'passthrough' : 'TPMPassthroughOptions', - 'emulator': 'TPMEmulatorOptions' }, + 'base': { 'type': 'TpmType' }, + 'discriminator': 'type', + 'data': { 'passthrough' : 'TPMPassthroughOptionsWrapper', + 'emulator': 'TPMEmulatorOptionsWrapper' }, 'if': 'CONFIG_TPM' } =20 ## diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index f8095d23d5..87d061e9bb 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -623,7 +623,7 @@ static TpmTypeOptions *tpm_emulator_get_tpm_options(TPM= Backend *tb) TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); TpmTypeOptions *options =3D g_new0(TpmTypeOptions, 1); =20 - options->type =3D TPM_TYPE_OPTIONS_KIND_EMULATOR; + options->type =3D TPM_TYPE_EMULATOR; options->u.emulator.data =3D QAPI_CLONE(TPMEmulatorOptions, tpm_emu->o= ptions); =20 return options; diff --git a/backends/tpm/tpm_passthrough.c b/backends/tpm/tpm_passthrough.c index 21b7459183..d5558fae6c 100644 --- a/backends/tpm/tpm_passthrough.c +++ b/backends/tpm/tpm_passthrough.c @@ -321,7 +321,7 @@ static TpmTypeOptions *tpm_passthrough_get_tpm_options(= TPMBackend *tb) { TpmTypeOptions *options =3D g_new0(TpmTypeOptions, 1); =20 - options->type =3D TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + options->type =3D TPM_TYPE_PASSTHROUGH; options->u.passthrough.data =3D QAPI_CLONE(TPMPassthroughOptions, TPM_PASSTHROUGH(tb)->options); =20 diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e00255f7ee..d6858407ad 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -925,10 +925,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) c, TpmModel_str(ti->model)); =20 monitor_printf(mon, " \\ %s: type=3D%s", - ti->id, TpmTypeOptionsKind_str(ti->options->type)); + ti->id, TpmType_str(ti->options->type)); =20 switch (ti->options->type) { - case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: + case TPM_TYPE_PASSTHROUGH: tpo =3D ti->options->u.passthrough.data; monitor_printf(mon, "%s%s%s%s", tpo->has_path ? ",path=3D" : "", @@ -936,11 +936,11 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) tpo->has_cancel_path ? ",cancel-path=3D" : "", tpo->has_cancel_path ? tpo->cancel_path : ""); break; - case TPM_TYPE_OPTIONS_KIND_EMULATOR: + case TPM_TYPE_EMULATOR: teo =3D ti->options->u.emulator.data; monitor_printf(mon, ",chardev=3D%s", teo->chardev); break; - case TPM_TYPE_OPTIONS_KIND__MAX: + case TPM_TYPE__MAX: break; } monitor_printf(mon, "\n"); --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631537519053210.09304838243315; Mon, 13 Sep 2021 05:51:59 -0700 (PDT) Received: from localhost ([::1]:45714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlRF-0001ET-Vk for importer@patchew.org; Mon, 13 Sep 2021 08:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000Em-Ei for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFP-0000g8-MG for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:46 -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-380-vrZaKja9NeyY73FerrmZ2A-1; Mon, 13 Sep 2021 08:39:41 -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 E46F81084688; Mon, 13 Sep 2021 12:39:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0261369A; Mon, 13 Sep 2021 12:39:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1F25A113853B; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536782; 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=sHLYav7WarZ13M6UwpgoWPQQS93llwmNuhFuc94ryMA=; b=Lcu+xMW5IRNHd4nwsBkpEpm+esQb9bDoNqko+AaG6g1Nc06+G35NO/60lu0Cjgp1+Z0h1Z vHYEOfCkrAMGEGIk0iRbcyQUNe0bR+hqaJcKvqlAvojsxn9ISv7q6glOvuEIMrFtdPkgDi 3L2rV2cycQfuigp3/pEXQJmM6QqbmeM= X-MC-Unique: vrZaKja9NeyY73FerrmZ2A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 06/22] qapi: Convert simple union MemoryDeviceInfo to flat one Date: Mon, 13 Sep 2021 14:39:16 +0200 Message-Id: <20210913123932.3306639-7-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, Eduardo Habkost , marcandre.lureau@redhat.com 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: 1631537521316100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union MemoryDeviceInfo to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Eduardo Habkost Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster --- qapi/machine.json | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 157712f006..b3bdcccb72 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1194,6 +1194,38 @@ } } =20 +## +# @MemoryDeviceInfoKind: +# +# Since: 6.1 +## +{ 'enum': 'MemoryDeviceInfoKind', + 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem' ] } + +## +# @PCDIMMDeviceInfoWrapper: +# +# Since: 6.1 +## +{ 'struct': 'PCDIMMDeviceInfoWrapper', + 'data': { 'data': 'PCDIMMDeviceInfo' } } + +## +# @VirtioPMEMDeviceInfoWrapper: +# +# Since: 6.1 +## +{ 'struct': 'VirtioPMEMDeviceInfoWrapper', + 'data': { 'data': 'VirtioPMEMDeviceInfo' } } + +## +# @VirtioMEMDeviceInfoWrapper: +# +# Since: 6.1 +## +{ 'struct': 'VirtioMEMDeviceInfoWrapper', + 'data': { 'data': 'VirtioMEMDeviceInfo' } } + ## # @MemoryDeviceInfo: # @@ -1205,10 +1237,12 @@ # Since: 2.1 ## { 'union': 'MemoryDeviceInfo', - 'data': { 'dimm': 'PCDIMMDeviceInfo', - 'nvdimm': 'PCDIMMDeviceInfo', - 'virtio-pmem': 'VirtioPMEMDeviceInfo', - 'virtio-mem': 'VirtioMEMDeviceInfo' + 'base': { 'type': 'MemoryDeviceInfoKind' }, + 'discriminator': 'type', + 'data': { 'dimm': 'PCDIMMDeviceInfoWrapper', + 'nvdimm': 'PCDIMMDeviceInfoWrapper', + 'virtio-pmem': 'VirtioPMEMDeviceInfoWrapper', + 'virtio-mem': 'VirtioMEMDeviceInfoWrapper' } } =20 --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631537928708415.62876215857057; Mon, 13 Sep 2021 05:58:48 -0700 (PDT) Received: from localhost ([::1]:35084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlXr-0005BG-Is for importer@patchew.org; Mon, 13 Sep 2021 08:58:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFV-0000Gq-8a for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFP-0000g4-M9 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:48 -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-360--zsB7rXwPKejCx1WFHd98w-1; Mon, 13 Sep 2021 08:39:41 -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 D282E19200C2 for ; Mon, 13 Sep 2021 12:39:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75AF31972D; Mon, 13 Sep 2021 12:39:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2297311384A2; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536782; 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=ktrEAxBOHAwYqia1hVzZqkyL4O/WEqFBWhYzqrrkrL0=; b=BBZiBU3oaHwbAYmaIyqgPr+waeyDZhhVkxgVVRTH9TcexqB6eD3u9buh+4FScxR07Xe/Jq Xbhq1b6IfiNmPZyUGo/BKCfaMxvOnX5UHjKQ0kXfC3YmJUCJ0G1we9j0PRTefpJryzS9BB 7v9t5H/RasfhZrfKAYRvUhHT/GCK80Q= X-MC-Unique: -zsB7rXwPKejCx1WFHd98w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 07/22] qapi: Convert simple union ChardevBackend to flat one Date: Mon, 13 Sep 2021 14:39:17 +0200 Message-Id: <20210913123932.3306639-8-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, Paolo Bonzini , eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631537929740100001 Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union ChardevBackend to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster --- qapi/char.json | 169 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 148 insertions(+), 21 deletions(-) diff --git a/qapi/char.json b/qapi/char.json index 9b18ee3305..69c136c138 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -407,6 +407,131 @@ 'base': 'ChardevCommon', 'if': 'CONFIG_SPICE_PROTOCOL' } =20 +## +# @ChardevBackendKind: +# +# Since: 6.1 +## +{ 'enum': 'ChardevBackendKind', + 'data': [ 'file', + 'serial', + 'parallel', + 'pipe', + 'socket', + 'udp', + 'pty', + 'null', + 'mux', + 'msmouse', + 'wctablet', + 'braille', + 'testdev', + 'stdio', + 'console', + { 'name': 'spicevmc', 'if': 'CONFIG_SPICE' }, + { 'name': 'spiceport', 'if': 'CONFIG_SPICE' }, + { 'name': 'qemu-vdagent', 'if': 'CONFIG_SPICE_PROTOCOL' }, + 'vc', + 'ringbuf', + # next one is just for compatibility + 'memory' ] } + +## +# @ChardevFileWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevFileWrapper', + 'data': { 'data': 'ChardevFile' } } + +## +# @ChardevHostdevWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevHostdevWrapper', + 'data': { 'data': 'ChardevHostdev' } } + +## +# @ChardevSocketWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevSocketWrapper', + 'data': { 'data': 'ChardevSocket' } } + +## +# @ChardevUdpWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevUdpWrapper', + 'data': { 'data': 'ChardevUdp' } } + +## +# @ChardevCommonWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevCommonWrapper', + 'data': { 'data': 'ChardevCommon' } } + +## +# @ChardevMuxWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevMuxWrapper', + 'data': { 'data': 'ChardevMux' } } + +## +# @ChardevStdioWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevStdioWrapper', + 'data': { 'data': 'ChardevStdio' } } + +## +# @ChardevSpiceChannelWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevSpiceChannelWrapper', + 'data': { 'data': 'ChardevSpiceChannel' } } + +## +# @ChardevSpicePortWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevSpicePortWrapper', + 'data': { 'data': 'ChardevSpicePort' } } + +## +# @ChardevQemuVDAgentWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevQemuVDAgentWrapper', + 'data': { 'data': 'ChardevQemuVDAgent' } } + +## +# @ChardevVCWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevVCWrapper', + 'data': { 'data': 'ChardevVC' } } + +## +# @ChardevRingbufWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ChardevRingbufWrapper', + 'data': { 'data': 'ChardevRingbuf' } } + ## # @ChardevBackend: # @@ -415,31 +540,33 @@ # Since: 1.4 (testdev since 2.2, wctablet since 2.9, vdagent since 6.1) ## { 'union': 'ChardevBackend', - 'data': { 'file': 'ChardevFile', - 'serial': 'ChardevHostdev', - 'parallel': 'ChardevHostdev', - 'pipe': 'ChardevHostdev', - 'socket': 'ChardevSocket', - 'udp': 'ChardevUdp', - 'pty': 'ChardevCommon', - 'null': 'ChardevCommon', - 'mux': 'ChardevMux', - 'msmouse': 'ChardevCommon', - 'wctablet': 'ChardevCommon', - 'braille': 'ChardevCommon', - 'testdev': 'ChardevCommon', - 'stdio': 'ChardevStdio', - 'console': 'ChardevCommon', - 'spicevmc': { 'type': 'ChardevSpiceChannel', + 'base': { 'type': 'ChardevBackendKind' }, + 'discriminator': 'type', + 'data': { 'file': 'ChardevFileWrapper', + 'serial': 'ChardevHostdevWrapper', + 'parallel': 'ChardevHostdevWrapper', + 'pipe': 'ChardevHostdevWrapper', + 'socket': 'ChardevSocketWrapper', + 'udp': 'ChardevUdpWrapper', + 'pty': 'ChardevCommonWrapper', + 'null': 'ChardevCommonWrapper', + 'mux': 'ChardevMuxWrapper', + 'msmouse': 'ChardevCommonWrapper', + 'wctablet': 'ChardevCommonWrapper', + 'braille': 'ChardevCommonWrapper', + 'testdev': 'ChardevCommonWrapper', + 'stdio': 'ChardevStdioWrapper', + 'console': 'ChardevCommonWrapper', + 'spicevmc': { 'type': 'ChardevSpiceChannelWrapper', 'if': 'CONFIG_SPICE' }, - 'spiceport': { 'type': 'ChardevSpicePort', + 'spiceport': { 'type': 'ChardevSpicePortWrapper', 'if': 'CONFIG_SPICE' }, - 'qemu-vdagent': { 'type': 'ChardevQemuVDAgent', + 'qemu-vdagent': { 'type': 'ChardevQemuVDAgentWrapper', 'if': 'CONFIG_SPICE_PROTOCOL' }, - 'vc': 'ChardevVC', - 'ringbuf': 'ChardevRingbuf', + 'vc': 'ChardevVCWrapper', + 'ringbuf': 'ChardevRingbufWrapper', # next one is just for compatibility - 'memory': 'ChardevRingbuf' } } + 'memory': 'ChardevRingbufWrapper' } } =20 ## # @ChardevReturn: --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631540008775928.4973358662427; Mon, 13 Sep 2021 06:33:28 -0700 (PDT) Received: from localhost ([::1]:48822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm5P-0003Ru-M0 for importer@patchew.org; Mon, 13 Sep 2021 09:33:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFb-0000SW-8a for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFV-0000jQ-0p for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-522-EYYJlTauPs-uiGkWiwN57A-1; Mon, 13 Sep 2021 08:39:43 -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 BF28B835DE9 for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7489260871; Mon, 13 Sep 2021 12:39:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 261DC11384A9; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536786; 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=2wn1ELk8RwrR9IErQxZ3/lJZHmn32PbbpKJKzUbjDpo=; b=g0inAWFFtvMbcAFMooZWNLRVRA7dIYvMbzgY9Lw8JV1UKMXAALB0egJUDOk/W81zXq4FxU JgEqiusPCvO7sjdBSvpnJhfdeF7N4KxBijhmqlw4kERixSiGayhud/nKPA3pag5VmAfNNb 4TriFLqYy1MpTUvXo+mBD7LO7e26wy0= X-MC-Unique: EYYJlTauPs-uiGkWiwN57A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 08/22] qapi: Convert simple union SocketAddressLegacy to flat one Date: Mon, 13 Sep 2021 14:39:18 +0200 Message-Id: <20210913123932.3306639-9-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , marcandre.lureau@redhat.com 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: 1631540010423100001 Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union SocketAddressLegacy to an equivalent flat one, with existing enum SocketAddressType replacing implicit enum type SocketAddressLegacyKind. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: "Daniel P. Berrang=C3=A9" Signed-off-by: Markus Armbruster --- qapi/sockets.json | 46 +++++++++++++++++++++++++++++++++++------- chardev/char-socket.c | 6 +++--- chardev/char-udp.c | 4 ++-- tests/unit/test-yank.c | 6 +++--- util/qemu-sockets.c | 8 ++++---- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/qapi/sockets.json b/qapi/sockets.json index 7866dc27d6..21ead16bb3 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -110,6 +110,38 @@ 'cid': 'str', 'port': 'str' } } =20 +## +# @InetSocketAddressWrapper: +# +# Since: 6.1 +## +{ 'struct': 'InetSocketAddressWrapper', + 'data': { 'data': 'InetSocketAddress' } } + +## +# @UnixSocketAddressWrapper: +# +# Since: 6.1 +## +{ 'struct': 'UnixSocketAddressWrapper', + 'data': { 'data': 'UnixSocketAddress' } } + +## +# @VsockSocketAddressWrapper: +# +# Since: 6.1 +## +{ 'struct': 'VsockSocketAddressWrapper', + 'data': { 'data': 'VsockSocketAddress' } } + +## +# @StringWrapper: +# +# Since: 6.1 +## +{ 'struct': 'StringWrapper', + 'data': { 'data': 'String' } } + ## # @SocketAddressLegacy: # @@ -117,18 +149,18 @@ # # Note: This type is deprecated in favor of SocketAddress. The # difference between SocketAddressLegacy and SocketAddress is that t= he -# latter is a flat union rather than a simple union. Flat is nicer -# because it avoids nesting on the wire, i.e. that form has fewer {}. - +# latter is has fewer {} on the wire. # # Since: 1.3 ## { 'union': 'SocketAddressLegacy', + 'base': { 'type': 'SocketAddressType' }, + 'discriminator': 'type', 'data': { - 'inet': 'InetSocketAddress', - 'unix': 'UnixSocketAddress', - 'vsock': 'VsockSocketAddress', - 'fd': 'String' } } + 'inet': 'InetSocketAddressWrapper', + 'unix': 'UnixSocketAddressWrapper', + 'vsock': 'VsockSocketAddressWrapper', + 'fd': 'StringWrapper' } } =20 ## # @SocketAddressType: diff --git a/chardev/char-socket.c b/chardev/char-socket.c index c43668cc15..836cfa0bc2 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1520,7 +1520,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, addr =3D g_new0(SocketAddressLegacy, 1); if (path) { UnixSocketAddress *q_unix; - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX; + addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; q_unix =3D addr->u.q_unix.data =3D g_new0(UnixSocketAddress, 1); q_unix->path =3D g_strdup(path); #ifdef CONFIG_LINUX @@ -1530,7 +1530,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, q_unix->abstract =3D abstract; #endif } else if (host) { - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(host), @@ -1543,7 +1543,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, .ipv6 =3D qemu_opt_get_bool(opts, "ipv6", 0), }; } else if (fd) { - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_FD; + addr->type =3D SOCKET_ADDRESS_TYPE_FD; addr->u.fd.data =3D g_new(String, 1); addr->u.fd.data->str =3D g_strdup(fd); } else { diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 16b5dbce58..6756e69924 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -165,7 +165,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevB= ackend *backend, qemu_chr_parse_common(opts, qapi_ChardevUdp_base(udp)); =20 addr =3D g_new0(SocketAddressLegacy, 1); - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(host), @@ -180,7 +180,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevB= ackend *backend, if (has_local) { udp->has_local =3D true; addr =3D g_new0(SocketAddressLegacy, 1); - addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; + addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); *addr->u.inet.data =3D (InetSocketAddress) { .host =3D g_strdup(localaddr), diff --git a/tests/unit/test-yank.c b/tests/unit/test-yank.c index 2383d2908c..e6c036a64d 100644 --- a/tests/unit/test-yank.c +++ b/tests/unit/test-yank.c @@ -88,7 +88,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_SOCKET, .u.socket.data =3D &(ChardevSocket) { .addr =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .type =3D SOCKET_ADDRESS_TYPE_INET, .u.inet.data =3D &addr->u.inet }, .has_server =3D true, @@ -102,7 +102,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_UDP, .u.udp.data =3D &(ChardevUdp) { .remote =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX, + .type =3D SOCKET_ADDRESS_TYPE_UNIX, .u.q_unix.data =3D &(UnixSocketAddress) { .path =3D (char *)"" } @@ -114,7 +114,7 @@ static void char_change_test(gconstpointer opaque) .type =3D CHARDEV_BACKEND_KIND_SOCKET, .u.socket.data =3D &(ChardevSocket) { .addr =3D &(SocketAddressLegacy) { - .type =3D SOCKET_ADDRESS_LEGACY_KIND_INET, + .type =3D SOCKET_ADDRESS_TYPE_INET, .u.inet.data =3D &(InetSocketAddress) { .host =3D (char *)"127.0.0.1", .port =3D (char *)"0" diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index c5043999e9..72216ef980 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1455,22 +1455,22 @@ SocketAddress *socket_address_flatten(SocketAddress= Legacy *addr_legacy) addr =3D g_new(SocketAddress, 1); =20 switch (addr_legacy->type) { - case SOCKET_ADDRESS_LEGACY_KIND_INET: + case SOCKET_ADDRESS_TYPE_INET: addr->type =3D SOCKET_ADDRESS_TYPE_INET; QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet, addr_legacy->u.inet.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_UNIX: + case SOCKET_ADDRESS_TYPE_UNIX: addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix, addr_legacy->u.q_unix.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_VSOCK: + case SOCKET_ADDRESS_TYPE_VSOCK: addr->type =3D SOCKET_ADDRESS_TYPE_VSOCK; QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock, addr_legacy->u.vsock.data); break; - case SOCKET_ADDRESS_LEGACY_KIND_FD: + case SOCKET_ADDRESS_TYPE_FD: addr->type =3D SOCKET_ADDRESS_TYPE_FD; QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data); break; --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631540085822190.6059677385124; Mon, 13 Sep 2021 06:34:45 -0700 (PDT) Received: from localhost ([::1]:51230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm6e-00051v-P4 for importer@patchew.org; Mon, 13 Sep 2021 09:34:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFa-0000QU-2d for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000iX-VB for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-245-4CQVA0WDOxW5Vy7hHv5y3w-1; Mon, 13 Sep 2021 08:39:43 -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 AA05A7BC for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12BD55D9D3; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 296561138461; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=uq705tZczjhon/0fpzP0cXD1902/1rvfuivOrwz0SUk=; b=WrGqUd+hyK9ubRTfC7jD77E3jMGB39hPHE0c8lZSbZovwYpR8InQ7bNcafvFu+kmKz3yis szoDtaLC01frkUFrKG5zYr4UAzs5LzIUPHFeOTieMi+LQqAcps3KZ5GZrim5qkT5xdMUr2 NZKxqVKcQbeucTm1SwwtSzW7xyP/z/8= X-MC-Unique: 4CQVA0WDOxW5Vy7hHv5y3w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 09/22] qapi: Convert simple union ImageInfoSpecific to flat one Date: Mon, 13 Sep 2021 14:39:19 +0200 Message-Id: <20210913123932.3306639-10-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: Kevin Wolf , jsnow@redhat.com, Hanna Reitz , eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631540087393100003 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union ImageInfoSpecific to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Implicit enum ImageInfoSpecificKind becomes explicit. It duplicates part of enum BlockdevDriver. We could reuse BlockdevDriver instead. Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Markus Armbruster Acked-by: Hanna Reitz --- qapi/block-core.json | 56 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c8ce1d9d5d..b2858b144f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -139,6 +139,49 @@ '*encryption-format': 'RbdImageEncryptionFormat' } } =20 +## +# @ImageInfoSpecificKind: +# +# Since: 6.1 +## +{ 'enum': 'ImageInfoSpecificKind', + 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd' ] } + +## +# @ImageInfoSpecificQCow2Wrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificQCow2Wrapper', + 'data': { 'data': 'ImageInfoSpecificQCow2' } } + +## +# @ImageInfoSpecificVmdkWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificVmdkWrapper', + 'data': { 'data': 'ImageInfoSpecificVmdk' } } + +## +# @ImageInfoSpecificLUKSWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificLUKSWrapper', + 'data': { 'data': 'QCryptoBlockInfoLUKS' } } +# If we need to add block driver specific parameters for +# LUKS in future, then we'll subclass QCryptoBlockInfoLUKS +# to define a ImageInfoSpecificLUKS + +## +# @ImageInfoSpecificRbdWrapper: +# +# Since: 6.1 +## +{ 'struct': 'ImageInfoSpecificRbdWrapper', + 'data': { 'data': 'ImageInfoSpecificRbd' } } + ## # @ImageInfoSpecific: # @@ -147,14 +190,13 @@ # Since: 1.7 ## { 'union': 'ImageInfoSpecific', + 'base': { 'type': 'ImageInfoSpecificKind' }, + 'discriminator': 'type', 'data': { - 'qcow2': 'ImageInfoSpecificQCow2', - 'vmdk': 'ImageInfoSpecificVmdk', - # If we need to add block driver specific parameters for - # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS - # to define a ImageInfoSpecificLUKS - 'luks': 'QCryptoBlockInfoLUKS', - 'rbd': 'ImageInfoSpecificRbd' + 'qcow2': 'ImageInfoSpecificQCow2Wrapper', + 'vmdk': 'ImageInfoSpecificVmdkWrapper', + 'luks': 'ImageInfoSpecificLUKSWrapper', + 'rbd': 'ImageInfoSpecificRbdWrapper' } } =20 ## --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539486640756.0331743158061; Mon, 13 Sep 2021 06:24:46 -0700 (PDT) Received: from localhost ([::1]:56736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlwz-00067D-L3 for importer@patchew.org; Mon, 13 Sep 2021 09:24:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFX-0000Jw-Ku for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000iV-6I for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -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-466-KMm3Go8aO3au-OpjTL5TCg-1; Mon, 13 Sep 2021 08:39:43 -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 AA5CD835DE3 for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12C5A5D9DD; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2CB601138467; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=OzWFqba3ChIj6kZtFj0igVf6keUieisQMci0dxHlOqQ=; b=TH0uNTDUsM9Qkxnhk1pLErjQ2glQUa8goEf6N8p+6mvax/KPXtdlPhVWeLWxUe0pMJTrn4 G6ExydxW2xlugrefY2BVY02I1bVV+JgZPW1LV1MCyewSdXdCTzIArmhqQQTZQt8JFWLlVg GRLpWYEeF6rwCtmkjqx+kRKo/baJLaY= X-MC-Unique: KMm3Go8aO3au-OpjTL5TCg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 10/22] qapi: Convert simple union TransactionAction to flat one Date: Mon, 13 Sep 2021 14:39:20 +0200 Message-Id: <20210913123932.3306639-11-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: Kevin Wolf , jsnow@redhat.com, Hanna Reitz , eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539488443100005 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, convert simple union TransactionAction to an equivalent flat one. Adds some boilerplate to the schema, which is a bit ugly, but a lot easier to maintain than the simple union feature. Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Markus Armbruster Acked-by: Hanna Reitz Reviewed-by: Eric Blake --- qapi/transaction.json | 111 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 12 deletions(-) diff --git a/qapi/transaction.json b/qapi/transaction.json index 894258d9e2..d7fc73d7df 100644 --- a/qapi/transaction.json +++ b/qapi/transaction.json @@ -38,6 +38,91 @@ { 'enum': 'ActionCompletionMode', 'data': [ 'individual', 'grouped' ] } =20 +## +# @TransactionActionKind: +# +# Since: 6.1 +## +{ 'enum': 'TransactionActionKind', + 'data': [ 'abort', 'block-dirty-bitmap-add', 'block-dirty-bitmap-remove', + 'block-dirty-bitmap-clear', 'block-dirty-bitmap-enable', + 'block-dirty-bitmap-disable', 'block-dirty-bitmap-merge', + 'blockdev-backup', 'blockdev-snapshot', + 'blockdev-snapshot-internal-sync', 'blockdev-snapshot-sync', + 'drive-backup' ] } + +## +# @AbortWrapper: +# +# Since: 6.1 +## +{ 'struct': 'AbortWrapper', + 'data': { 'data': 'Abort' } } + +## +# @BlockDirtyBitmapAddWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockDirtyBitmapAddWrapper', + 'data': { 'data': 'BlockDirtyBitmapAdd' } } + +## +# @BlockDirtyBitmapWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockDirtyBitmapWrapper', + 'data': { 'data': 'BlockDirtyBitmap' } } + +## +# @BlockDirtyBitmapMergeWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockDirtyBitmapMergeWrapper', + 'data': { 'data': 'BlockDirtyBitmapMerge' } } + +## +# @BlockdevBackupWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockdevBackupWrapper', + 'data': { 'data': 'BlockdevBackup' } } + +## +# @BlockdevSnapshotWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockdevSnapshotWrapper', + 'data': { 'data': 'BlockdevSnapshot' } } + +## +# @BlockdevSnapshotInternalWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockdevSnapshotInternalWrapper', + 'data': { 'data': 'BlockdevSnapshotInternal' } } + +## +# @BlockdevSnapshotSyncWrapper: +# +# Since: 6.1 +## +{ 'struct': 'BlockdevSnapshotSyncWrapper', + 'data': { 'data': 'BlockdevSnapshotSync' } } + +## +# @DriveBackupWrapper: +# +# Since: 6.1 +## +{ 'struct': 'DriveBackupWrapper', + 'data': { 'data': 'DriveBackup' } } + ## # @TransactionAction: # @@ -60,19 +145,21 @@ # Since: 1.1 ## { 'union': 'TransactionAction', + 'base': { 'type': 'TransactionActionKind' }, + 'discriminator': 'type', 'data': { - 'abort': 'Abort', - 'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd', - 'block-dirty-bitmap-remove': 'BlockDirtyBitmap', - 'block-dirty-bitmap-clear': 'BlockDirtyBitmap', - 'block-dirty-bitmap-enable': 'BlockDirtyBitmap', - 'block-dirty-bitmap-disable': 'BlockDirtyBitmap', - 'block-dirty-bitmap-merge': 'BlockDirtyBitmapMerge', - 'blockdev-backup': 'BlockdevBackup', - 'blockdev-snapshot': 'BlockdevSnapshot', - 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', - 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', - 'drive-backup': 'DriveBackup' + 'abort': 'AbortWrapper', + 'block-dirty-bitmap-add': 'BlockDirtyBitmapAddWrapper', + 'block-dirty-bitmap-remove': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-clear': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-enable': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-disable': 'BlockDirtyBitmapWrapper', + 'block-dirty-bitmap-merge': 'BlockDirtyBitmapMergeWrapper', + 'blockdev-backup': 'BlockdevBackupWrapper', + 'blockdev-snapshot': 'BlockdevSnapshotWrapper', + 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternalWrapper= ', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSyncWrapper', + 'drive-backup': 'DriveBackupWrapper' } } =20 ## --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631538350989600.2562355327825; Mon, 13 Sep 2021 06:05:50 -0700 (PDT) Received: from localhost ([::1]:45138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlef-0003pC-T9 for importer@patchew.org; Mon, 13 Sep 2021 09:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFZ-0000O3-63 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000j3-Ui for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:52 -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-FLLm82AlMJ6DLof6xiStJg-1; Mon, 13 Sep 2021 08:39:44 -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 430DC19200C0 for ; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 170626B55B; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2FFE31138468; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536785; 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=LPHqzoujVnw5l+fQuNVLEfClwO6/UGwFf+Yx7qYQtFI=; b=I4K393D2cML2+M4N2CBn+G+RThf4J5Kz08PbjveCj60FcGShzbNoJBhIadu7UJwxvTVWJL ifQQ98a3roGkEg2OySb9+wSw8MSutzCA4JB9YPzpaDuv23ILfcWBC4pqf+6ERtBjfTu60p BWJTuAKbKP39/NrpE9zJ/ORodD5/hVk= X-MC-Unique: FLLm82AlMJ6DLof6xiStJg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 11/22] tests/qapi-schema: Prepare for simple union UserDefListUnion removal Date: Mon, 13 Sep 2021 14:39:21 +0200 Message-Id: <20210913123932.3306639-12-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631538380859100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, simple union UserDefListUnion has to go. It is used to cover arrays. The next few commits will eliminate its uses, and then it gets deleted. As a first step, provide struct ArrayStruct for the tests to be rewritten. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 16 ++++++++++++++++ tests/qapi-schema/qapi-schema-test.out | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 3c43e14e22..b2d795cb19 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -140,6 +140,22 @@ 'sizes': ['size'], 'any': ['any'], 'user': ['Status'] } } # intentional forward ref. to sub-module +{ 'struct': 'ArrayStruct', + 'data': { 'integer': ['int'], + 's8': ['int8'], + 's16': ['int16'], + 's32': ['int32'], + 's64': ['int64'], + 'u8': ['uint8'], + 'u16': ['uint16'], + 'u32': ['uint32'], + 'u64': ['uint64'], + 'number': ['number'], + 'boolean': ['bool'], + 'string': ['str'], + '*sz': ['size'], + '*any': ['any'], + '*user': ['Status'] } } # intentional forward ref. to sub-modu= le =20 # for testing sub-modules { 'include': 'include/sub-module.json' } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index d557fe2d89..7a488c1d06 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -189,6 +189,22 @@ object UserDefListUnion case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper case user: q_obj_StatusList-wrapper +object ArrayStruct + member integer: intList optional=3DFalse + member s8: int8List optional=3DFalse + member s16: int16List optional=3DFalse + member s32: int32List optional=3DFalse + member s64: int64List optional=3DFalse + member u8: uint8List optional=3DFalse + member u16: uint16List optional=3DFalse + member u32: uint32List optional=3DFalse + member u64: uint64List optional=3DFalse + member number: numberList optional=3DFalse + member boolean: boolList optional=3DFalse + member string: strList optional=3DFalse + member sz: sizeList optional=3DTrue + member any: anyList optional=3DTrue + member user: StatusList optional=3DTrue include include/sub-module.json command user-def-cmd None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539611795302.11338603911304; Mon, 13 Sep 2021 06:26:51 -0700 (PDT) Received: from localhost ([::1]:33692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlz0-0001Fg-Ir for importer@patchew.org; Mon, 13 Sep 2021 09:26:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFX-0000J4-Df for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000iT-92 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -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-466-FCEFO8uvOB2n04VxjEpuKw-1; Mon, 13 Sep 2021 08:39:43 -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 944742E77 for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 19A295FC13; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 339181138469; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=TZbnq8tDgxVTpOFOSGSiuqu99zzRHN47TdFtQ4vNLk8=; b=evKyDaS1dHuL6QXooBRePsiQ0it8gBNmDjvcZO7+FATIJS+kAez/kZ/E26cqnLDXX33bap KuRGplk99w0nbzGAMZLt9CzGIIzxVag5G82cvcQD1g2MA+y2HJpJEiEQv+Rd6L8DH+dEpp 2Ant289HJSPJKaYIMwnKmbLgba/T+fI= X-MC-Unique: FCEFO8uvOB2n04VxjEpuKw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 12/22] test-qobject-input-visitor: Wean off UserDefListUnion Date: Mon, 13 Sep 2021 14:39:22 +0200 Message-Id: <20210913123932.3306639-13-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539613796100001 Content-Type: text/plain; charset="utf-8" The test_visitor_in_list_union_FOO() use simple union UserDefListUnion to cover lists of builtin types. Rewrite as test_visitor_in_list_struct(), using struct ArrayStruct and a lot less code. test_visitor_in_fail_union_list() uses UserDefListUnion to cover "variant members don't match the discriminator value". Cover that in test_visitor_in_fail_union_flat() instead, and drop test_visitor_in_fail_union_list(). Appropriating the former for this purpose is okay, because it actually failed due to missing discriminator, which is still covered by test_visitor_in_fail_union_flat_no_discrim(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-qobject-input-visitor.c | 460 ++++++++---------------- 1 file changed, 148 insertions(+), 312 deletions(-) diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index e41b91a2a6..6f59a7f432 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -464,6 +464,151 @@ static void test_visitor_in_list(TestInputVisitorData= *data, g_assert(!head); } =20 +static void test_visitor_in_list_struct(TestInputVisitorData *data, + const void *unused) +{ + const char *int_member[] =3D { + "integer", "s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64" }; + g_autoptr(GString) json =3D g_string_new(""); + int i, j; + const char *sep; + g_autoptr(ArrayStruct) arrs =3D NULL; + Visitor *v; + intList *int_list; + int8List *s8_list; + int16List *s16_list; + int32List *s32_list; + int64List *s64_list; + uint8List *u8_list; + uint16List *u16_list; + uint32List *u32_list; + uint64List *u64_list; + numberList *num_list; + boolList *bool_list; + strList *str_list; + + g_string_append_printf(json, "{"); + + for (i =3D 0; i < G_N_ELEMENTS(int_member); i++) { + g_string_append_printf(json, "'%s': [", int_member[i]); + sep =3D ""; + for (j =3D 0; j < 32; j++) { + g_string_append_printf(json, "%s%d", sep, j); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + } + + g_string_append_printf(json, "'number': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s%f", sep, (double)i / 3); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + + g_string_append_printf(json, "'boolean': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s%s", + sep, i % 3 =3D=3D 0 ? "true" : "false"); + sep =3D ", "; + } + g_string_append_printf(json, "], "); + + g_string_append_printf(json, "'string': ["); + sep =3D ""; + for (i =3D 0; i < 32; i++) { + g_string_append_printf(json, "%s'%d'", sep, i); + sep =3D ", "; + } + g_string_append_printf(json, "]"); + + g_string_append_printf(json, "}"); + + v =3D visitor_input_test_init_raw(data, json->str); + visit_type_ArrayStruct(v, NULL, &arrs, &error_abort); + + i =3D 0; + for (int_list =3D arrs->integer; int_list; int_list =3D int_list->next= ) { + g_assert_cmpint(int_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s8_list =3D arrs->s8; s8_list; s8_list =3D s8_list->next) { + g_assert_cmpint(s8_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s16_list =3D arrs->s16; s16_list; s16_list =3D s16_list->next) { + g_assert_cmpint(s16_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s32_list =3D arrs->s32; s32_list; s32_list =3D s32_list->next) { + g_assert_cmpint(s32_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (s64_list =3D arrs->s64; s64_list; s64_list =3D s64_list->next) { + g_assert_cmpint(s64_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u8_list =3D arrs->u8; u8_list; u8_list =3D u8_list->next) { + g_assert_cmpint(u8_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u16_list =3D arrs->u16; u16_list; u16_list =3D u16_list->next) { + g_assert_cmpint(u16_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u32_list =3D arrs->u32; u32_list; u32_list =3D u32_list->next) { + g_assert_cmpint(u32_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (u64_list =3D arrs->u64; u64_list; u64_list =3D u64_list->next) { + g_assert_cmpint(u64_list->value, =3D=3D, i); + i++; + } + + i =3D 0; + for (num_list =3D arrs->number; num_list; num_list =3D num_list->next)= { + char expected[32], actual[32]; + + sprintf(expected, "%.6f", (double)i / 3); + sprintf(actual, "%.6f", num_list->value); + g_assert_cmpstr(expected, =3D=3D, actual); + i++; + } + + i =3D 0; + for (bool_list =3D arrs->boolean; bool_list; bool_list =3D bool_list->= next) { + g_assert_cmpint(bool_list->value, =3D=3D, i % 3 =3D=3D 0); + i++; + } + + i =3D 0; + for (str_list =3D arrs->string; str_list; str_list =3D str_list->next)= { + char expected[32]; + + sprintf(expected, "%d", i); + g_assert_cmpstr(str_list->value, =3D=3D, expected); + i++; + } +} + static void test_visitor_in_any(TestInputVisitorData *data, const void *unused) { @@ -682,276 +827,6 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, qapi_free_AltEnumInt(asi); } =20 -static void test_list_union_integer_helper(TestInputVisitorData *data, - const void *unused, - UserDefListUnionKind kind) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%d", i); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }", - UserDefListUnionKind_str(kind), - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, kind); - - switch (kind) { - case USER_DEF_LIST_UNION_KIND_INTEGER: { - intList *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.integer.data; - elem; elem =3D elem->next, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S8: { - int8List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s8.data; elem; elem =3D elem->nex= t, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S16: { - int16List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s16.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S32: { - int32List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s32.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S64: { - int64List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.s64.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U8: { - uint8List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u8.data; elem; elem =3D elem->nex= t, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U16: { - uint16List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u16.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U32: { - uint32List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u32.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U64: { - uint64List *elem =3D NULL; - for (i =3D 0, elem =3D cvalue->u.u64.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, i); - } - break; - } - default: - g_assert_not_reached(); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -static void test_visitor_in_list_union_int(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_INTEGER); -} - -static void test_visitor_in_list_union_int8(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S8); -} - -static void test_visitor_in_list_union_int16(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S16); -} - -static void test_visitor_in_list_union_int32(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S32); -} - -static void test_visitor_in_list_union_int64(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_S64); -} - -static void test_visitor_in_list_union_uint8(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U8); -} - -static void test_visitor_in_list_union_uint16(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U16); -} - -static void test_visitor_in_list_union_uint32(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U32); -} - -static void test_visitor_in_list_union_uint64(TestInputVisitorData *data, - const void *unused) -{ - test_list_union_integer_helper(data, unused, - USER_DEF_LIST_UNION_KIND_U64); -} - -static void test_visitor_in_list_union_bool(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - boolList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%s", - (i % 3 =3D=3D 0) ? "true" : "false"); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'boolean', 'data': [ %s= ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_BOOLEAN= ); - - for (i =3D 0, elem =3D cvalue->u.boolean.data; elem; elem =3D elem->ne= xt, i++) { - g_assert_cmpint(elem->value, =3D=3D, (i % 3 =3D=3D 0) ? 1 : 0); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -static void test_visitor_in_list_union_string(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - strList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "'%d'", i); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s = ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_STRING); - - for (i =3D 0, elem =3D cvalue->u.string.data; elem; elem =3D elem->nex= t, i++) { - gchar str[8]; - sprintf(str, "%d", i); - g_assert_cmpstr(elem->value, =3D=3D, str); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - -#define DOUBLE_STR_MAX 16 - -static void test_visitor_in_list_union_number(TestInputVisitorData *data, - const void *unused) -{ - g_autoptr(UserDefListUnion) cvalue =3D NULL; - numberList *elem =3D NULL; - Visitor *v; - GString *gstr_list =3D g_string_new(""); - GString *gstr_union =3D g_string_new(""); - int i; - - for (i =3D 0; i < 32; i++) { - g_string_append_printf(gstr_list, "%f", (double)i / 3); - if (i !=3D 31) { - g_string_append(gstr_list, ", "); - } - } - g_string_append_printf(gstr_union, "{ 'type': 'number', 'data': [ %s = ] }", - gstr_list->str); - v =3D visitor_input_test_init_raw(data, gstr_union->str); - - visit_type_UserDefListUnion(v, NULL, &cvalue, &error_abort); - g_assert(cvalue !=3D NULL); - g_assert_cmpint(cvalue->type, =3D=3D, USER_DEF_LIST_UNION_KIND_NUMBER); - - for (i =3D 0, elem =3D cvalue->u.number.data; elem; elem =3D elem->nex= t, i++) { - GString *double_expected =3D g_string_new(""); - GString *double_actual =3D g_string_new(""); - - g_string_printf(double_expected, "%.6f", (double)i / 3); - g_string_printf(double_actual, "%.6f", elem->value); - g_assert_cmpstr(double_expected->str, =3D=3D, double_actual->str); - - g_string_free(double_expected, true); - g_string_free(double_actual, true); - } - - g_string_free(gstr_union, true); - g_string_free(gstr_list, true); -} - static void input_visitor_test_add(const char *testpath, const void *user_data, void (*test_func)(TestInputVisitorData = *data, @@ -1184,21 +1059,6 @@ static void test_visitor_in_fail_list_nested(TestInp= utVisitorData *data, visit_end_list(v, NULL); } =20 -static void test_visitor_in_fail_union_list(TestInputVisitorData *data, - const void *unused) -{ - UserDefListUnion *tmp =3D NULL; - Error *err =3D NULL; - Visitor *v; - - v =3D visitor_input_test_init(data, - "{ 'type': 'integer', 'data' : [ 'string' = ] }"); - - visit_type_UserDefListUnion(v, NULL, &tmp, &err); - error_free_or_abort(&err); - g_assert(!tmp); -} - static void test_visitor_in_fail_union_flat(TestInputVisitorData *data, const void *unused) { @@ -1206,7 +1066,7 @@ static void test_visitor_in_fail_union_flat(TestInput= VisitorData *data, Error *err =3D NULL; Visitor *v; =20 - v =3D visitor_input_test_init(data, "{ 'string': 'c', 'integer': 41, '= boolean': true }"); + v =3D visitor_input_test_init(data, "{ 'enum1': 'value2', 'string': 'c= ', 'integer': 41, 'boolean': true }"); =20 visit_type_UserDefFlatUnion(v, NULL, &tmp, &err); error_free_or_abort(&err); @@ -1310,6 +1170,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_struct); input_visitor_test_add("/visitor/input/struct-nested", NULL, test_visitor_in_struct_nested); + input_visitor_test_add("/visitor/input/list2", + NULL, test_visitor_in_list_struct); input_visitor_test_add("/visitor/input/list", NULL, test_visitor_in_list); input_visitor_test_add("/visitor/input/any", @@ -1326,30 +1188,6 @@ int main(int argc, char **argv) NULL, test_visitor_in_wrong_type); input_visitor_test_add("/visitor/input/alternate-number", NULL, test_visitor_in_alternate_number); - input_visitor_test_add("/visitor/input/list_union/int", - NULL, test_visitor_in_list_union_int); - input_visitor_test_add("/visitor/input/list_union/int8", - NULL, test_visitor_in_list_union_int8); - input_visitor_test_add("/visitor/input/list_union/int16", - NULL, test_visitor_in_list_union_int16); - input_visitor_test_add("/visitor/input/list_union/int32", - NULL, test_visitor_in_list_union_int32); - input_visitor_test_add("/visitor/input/list_union/int64", - NULL, test_visitor_in_list_union_int64); - input_visitor_test_add("/visitor/input/list_union/uint8", - NULL, test_visitor_in_list_union_uint8); - input_visitor_test_add("/visitor/input/list_union/uint16", - NULL, test_visitor_in_list_union_uint16); - input_visitor_test_add("/visitor/input/list_union/uint32", - NULL, test_visitor_in_list_union_uint32); - input_visitor_test_add("/visitor/input/list_union/uint64", - NULL, test_visitor_in_list_union_uint64); - input_visitor_test_add("/visitor/input/list_union/bool", - NULL, test_visitor_in_list_union_bool); - input_visitor_test_add("/visitor/input/list_union/str", - NULL, test_visitor_in_list_union_string); - input_visitor_test_add("/visitor/input/list_union/number", - NULL, test_visitor_in_list_union_number); input_visitor_test_add("/visitor/input/fail/struct", NULL, test_visitor_in_fail_struct); input_visitor_test_add("/visitor/input/fail/struct-nested", @@ -1368,8 +1206,6 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_union_flat_no_discri= m); input_visitor_test_add("/visitor/input/fail/alternate", NULL, test_visitor_in_fail_alternate); - input_visitor_test_add("/visitor/input/fail/union-list", - NULL, test_visitor_in_fail_union_list); input_visitor_test_add("/visitor/input/qapi-introspect", NULL, test_visitor_in_qmp_introspect); =20 --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539115550734.816985391197; Mon, 13 Sep 2021 06:18:35 -0700 (PDT) Received: from localhost ([::1]:42812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlqz-0004uX-B1 for importer@patchew.org; Mon, 13 Sep 2021 09:18:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFb-0000SR-0X for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000im-Vp for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-271-I1YRi9XBMF2mTsZHXz7cVw-1; Mon, 13 Sep 2021 08:39:43 -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 F29D5108468B for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25C115D9DE; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 37C9C11380A9; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536785; 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=TbrvfA6vv0Mz6QzrL8SKC7k0DUYniuJZGd22dsMA24k=; b=YbmFiFMueU5TSFw7XtvrYnW6lDGdLhbMYXoU4ONUyTvOcFLO8ckbLT/XCASzYDQUovEEiS VJ5uU3xF1BUmbMLkRb7DN0vtlH9aNnod/3q//HfitdifsR/gMIcEh0zn7yF94F2zxnXLES yxooLpU6LoDtzkq4vKPfmQpxEGQwNz4= X-MC-Unique: I1YRi9XBMF2mTsZHXz7cVw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 13/22] test-qobject-output-visitor: Wean off UserDefListUnion Date: Mon, 13 Sep 2021 14:39:23 +0200 Message-Id: <20210913123932.3306639-14-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539116481100001 Content-Type: text/plain; charset="utf-8" The test_visitor_out_list_union_FOO() use simple union UserDefListUnion to cover lists of builtin types. Rewrite as test_visitor_out_list_struct(), using struct ArrayStruct and a lot less code. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-qobject-output-visitor.c | 391 ++++++----------------- 1 file changed, 93 insertions(+), 298 deletions(-) diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 9dc1e075e7..34d67a439a 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -437,289 +437,118 @@ static void test_visitor_out_null(TestOutputVisitor= Data *data, g_assert(qobject_type(nil) =3D=3D QTYPE_QNULL); } =20 -static void init_list_union(UserDefListUnion *cvalue) -{ - int i; - switch (cvalue->type) { - case USER_DEF_LIST_UNION_KIND_INTEGER: { - intList **tail =3D &cvalue->u.integer.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S8: { - int8List **tail =3D &cvalue->u.s8.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S16: { - int16List **tail =3D &cvalue->u.s16.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S32: { - int32List **tail =3D &cvalue->u.s32.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_S64: { - int64List **tail =3D &cvalue->u.s64.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U8: { - uint8List **tail =3D &cvalue->u.u8.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U16: { - uint16List **tail =3D &cvalue->u.u16.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U32: { - uint32List **tail =3D &cvalue->u.u32.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_U64: { - uint64List **tail =3D &cvalue->u.u64.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, i); - } - break; - } - case USER_DEF_LIST_UNION_KIND_BOOLEAN: { - boolList **tail =3D &cvalue->u.boolean.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, QEMU_IS_ALIGNED(i, 3)); - } - break; - } - case USER_DEF_LIST_UNION_KIND_STRING: { - strList **tail =3D &cvalue->u.string.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, g_strdup_printf("%d", i)); - } - break; - } - case USER_DEF_LIST_UNION_KIND_NUMBER: { - numberList **tail =3D &cvalue->u.number.data; - for (i =3D 0; i < 32; i++) { - QAPI_LIST_APPEND(tail, (double)i / 3); - } - break; - } - default: - g_assert_not_reached(); - } -} - -static void check_list_union(QObject *qobj, - UserDefListUnionKind kind) +static void test_visitor_out_list_struct(TestOutputVisitorData *data, + const void *unused) { + const char *int_member[] =3D { + "integer", "s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64" }; + g_autoptr(ArrayStruct) arrs =3D g_new0(ArrayStruct, 1); + int i, j; QDict *qdict; QList *qlist; - int i; + QListEntry *e; =20 - qdict =3D qobject_to(QDict, qobj); - g_assert(qdict); - g_assert(qdict_haskey(qdict, "data")); - qlist =3D qlist_copy(qobject_to(QList, qdict_get(qdict, "data"))); - - switch (kind) { - case USER_DEF_LIST_UNION_KIND_U8: - case USER_DEF_LIST_UNION_KIND_U16: - case USER_DEF_LIST_UNION_KIND_U32: - case USER_DEF_LIST_UNION_KIND_U64: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - uint64_t val; - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_assert(qnum_get_try_uint(qvalue, &val)); - g_assert_cmpint(val, =3D=3D, i); - qobject_unref(qlist_pop(qlist)); - } - break; - - case USER_DEF_LIST_UNION_KIND_S8: - case USER_DEF_LIST_UNION_KIND_S16: - case USER_DEF_LIST_UNION_KIND_S32: - case USER_DEF_LIST_UNION_KIND_S64: - /* - * All integer elements in JSON arrays get stored into QNums - * when we convert to QObjects, so we can check them all in - * the same fashion, so simply fall through here. - */ - case USER_DEF_LIST_UNION_KIND_INTEGER: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - int64_t val; - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_assert(qnum_get_try_int(qvalue, &val)); - g_assert_cmpint(val, =3D=3D, i); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_BOOLEAN: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QBool *qvalue; - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QBool, tmp); - g_assert_cmpint(qbool_get_bool(qvalue), =3D=3D, i % 3 =3D=3D 0= ); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_STRING: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QString *qvalue; - gchar str[8]; - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QString, tmp); - sprintf(str, "%d", i); - g_assert_cmpstr(qstring_get_str(qvalue), =3D=3D, str); - qobject_unref(qlist_pop(qlist)); - } - break; - case USER_DEF_LIST_UNION_KIND_NUMBER: - for (i =3D 0; i < 32; i++) { - QObject *tmp; - QNum *qvalue; - GString *double_expected =3D g_string_new(""); - GString *double_actual =3D g_string_new(""); - - tmp =3D qlist_peek(qlist); - g_assert(tmp); - qvalue =3D qobject_to(QNum, tmp); - g_string_printf(double_expected, "%.6f", (double)i / 3); - g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue)= ); - g_assert_cmpstr(double_actual->str, =3D=3D, double_expected->s= tr); - - qobject_unref(qlist_pop(qlist)); - g_string_free(double_expected, true); - g_string_free(double_actual, true); - } - break; - default: - g_assert_not_reached(); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->integer, i); } - qobject_unref(qlist); -} =20 -static void test_list_union(TestOutputVisitorData *data, - const void *unused, - UserDefListUnionKind kind) -{ - UserDefListUnion *cvalue =3D g_new0(UserDefListUnion, 1); - QObject *obj; + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s8, i); + } =20 - cvalue->type =3D kind; - init_list_union(cvalue); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s16, i); + } =20 - visit_type_UserDefListUnion(data->ov, NULL, &cvalue, &error_abort); + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s32, i); + } =20 - obj =3D visitor_get(data); - check_list_union(obj, cvalue->type); - qapi_free_UserDefListUnion(cvalue); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->s64, i); + } =20 -static void test_visitor_out_list_union_int(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_INTEGER); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u8, i); + } =20 -static void test_visitor_out_list_union_int8(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S8); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u16, i); + } =20 -static void test_visitor_out_list_union_int16(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S16); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u32, i); + } =20 -static void test_visitor_out_list_union_int32(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S32); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->u64, i); + } =20 -static void test_visitor_out_list_union_int64(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_S64); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->number, (double)i / 3); + } =20 -static void test_visitor_out_list_union_uint8(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U8); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->boolean, QEMU_IS_ALIGNED(i, 3)); + } =20 -static void test_visitor_out_list_union_uint16(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U16); -} + for (i =3D 31; i >=3D 0; i--) { + QAPI_LIST_PREPEND(arrs->string, g_strdup_printf("%d", i)); + } =20 -static void test_visitor_out_list_union_uint32(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U32); -} + visit_type_ArrayStruct(data->ov, NULL, &arrs, &error_abort); =20 -static void test_visitor_out_list_union_uint64(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_U64); -} + qdict =3D qobject_to(QDict, visitor_get(data)); + g_assert(qdict); =20 -static void test_visitor_out_list_union_bool(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_BOOLEAN); -} + for (i =3D 0; i < G_N_ELEMENTS(int_member); i++) { + qlist =3D qdict_get_qlist(qdict, int_member[i]); + g_assert(qlist); + j =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QNum *qvalue =3D qobject_to(QNum, qlist_entry_obj(e)); + g_assert(qvalue); + g_assert_cmpint(qnum_get_int(qvalue), =3D=3D, j); + j++; + } + } =20 -static void test_visitor_out_list_union_str(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_STRING); -} + qlist =3D qdict_get_qlist(qdict, "number"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QNum *qvalue =3D qobject_to(QNum, qlist_entry_obj(e)); + char expected[32], actual[32]; =20 -static void test_visitor_out_list_union_number(TestOutputVisitorData *data, - const void *unused) -{ - test_list_union(data, unused, USER_DEF_LIST_UNION_KIND_NUMBER); + g_assert(qvalue); + sprintf(expected, "%.6f", (double)i / 3); + sprintf(actual, "%.6f", qnum_get_double(qvalue)); + g_assert_cmpstr(actual, =3D=3D, expected); + i++; + } + + qlist =3D qdict_get_qlist(qdict, "boolean"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QBool *qvalue =3D qobject_to(QBool, qlist_entry_obj(e)); + g_assert(qvalue); + g_assert_cmpint(qbool_get_bool(qvalue), =3D=3D, i % 3 =3D=3D 0); + i++; + } + + qlist =3D qdict_get_qlist(qdict, "string"); + g_assert(qlist); + i =3D 0; + QLIST_FOREACH_ENTRY(qlist, e) { + QString *qvalue =3D qobject_to(QString, qlist_entry_obj(e)); + char expected[32]; + + g_assert(qvalue); + sprintf(expected, "%d", i); + g_assert_cmpstr(qstring_get_str(qvalue), =3D=3D, expected); + i++; + } } =20 static void output_visitor_test_add(const char *testpath, @@ -764,42 +593,8 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_alternate); output_visitor_test_add("/visitor/output/null", &out_visitor_data, test_visitor_out_null); - output_visitor_test_add("/visitor/output/list_union/int", - &out_visitor_data, - test_visitor_out_list_union_int); - output_visitor_test_add("/visitor/output/list_union/int8", - &out_visitor_data, - test_visitor_out_list_union_int8); - output_visitor_test_add("/visitor/output/list_union/int16", - &out_visitor_data, - test_visitor_out_list_union_int16); - output_visitor_test_add("/visitor/output/list_union/int32", - &out_visitor_data, - test_visitor_out_list_union_int32); - output_visitor_test_add("/visitor/output/list_union/int64", - &out_visitor_data, - test_visitor_out_list_union_int64); - output_visitor_test_add("/visitor/output/list_union/uint8", - &out_visitor_data, - test_visitor_out_list_union_uint8); - output_visitor_test_add("/visitor/output/list_union/uint16", - &out_visitor_data, - test_visitor_out_list_union_uint16); - output_visitor_test_add("/visitor/output/list_union/uint32", - &out_visitor_data, - test_visitor_out_list_union_uint32); - output_visitor_test_add("/visitor/output/list_union/uint64", - &out_visitor_data, - test_visitor_out_list_union_uint64); - output_visitor_test_add("/visitor/output/list_union/bool", - &out_visitor_data, - test_visitor_out_list_union_bool); - output_visitor_test_add("/visitor/output/list_union/string", - &out_visitor_data, - test_visitor_out_list_union_str); - output_visitor_test_add("/visitor/output/list_union/number", - &out_visitor_data, - test_visitor_out_list_union_number); + output_visitor_test_add("/visitor/output/list_struct", + &out_visitor_data, test_visitor_out_list_struc= t); =20 g_test_run(); =20 --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631537707619363.20417713729967; Mon, 13 Sep 2021 05:55:07 -0700 (PDT) Received: from localhost ([::1]:54536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlUI-0007Yn-19 for importer@patchew.org; Mon, 13 Sep 2021 08:55:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFX-0000II-6e for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000jJ-7K for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:50 -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-520-5iCb_-cXPJ2pZseKz4HHkQ-1; Mon, 13 Sep 2021 08:39:43 -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 6250B802936 for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30FFA19724; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3B18011380AB; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536786; 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=qBrNTa4nTrGn7tAHVLs07vRQ5OsPrMx6bxdZ1yCDdtw=; b=FSnMGadZ5LAVME7DLzUNkx2AADtyDojOYsrD6A3SebeVOcwq9VB6ADLIDschnbn8XvCOa2 2YcWMCl5GuB5/PYVCqDfRstN9kdEtENsA7qisOLj6l0JAT7hj33voa1FbauJv5pMjXoyHS Rp7trJBpH5misMYYEI6eP/0OIt/5zsU= X-MC-Unique: 5iCb_-cXPJ2pZseKz4HHkQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 14/22] test-clone-visitor: Wean off UserDefListUnion Date: Mon, 13 Sep 2021 14:39:24 +0200 Message-Id: <20210913123932.3306639-15-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631537709880100001 Content-Type: text/plain; charset="utf-8" test_clone_complex1() uses simple union UserDefListUnion to cover unions. Use UserDefFlatUnion instead. Arrays are still covered by test_clone_complex3(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-clone-visitor.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 4944b3d857..8357a90e60 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -99,18 +99,26 @@ static void test_clone_empty(void) =20 static void test_clone_complex1(void) { - UserDefListUnion *src, *dst; + UserDefFlatUnion *src, *dst; =20 - src =3D g_new0(UserDefListUnion, 1); - src->type =3D USER_DEF_LIST_UNION_KIND_STRING; + src =3D g_new0(UserDefFlatUnion, 1); + src->integer =3D 123; + src->string =3D g_strdup("abc"); + src->enum1 =3D ENUM_ONE_VALUE1; + src->u.value1.boolean =3D true; =20 - dst =3D QAPI_CLONE(UserDefListUnion, src); + dst =3D QAPI_CLONE(UserDefFlatUnion, src); g_assert(dst); - g_assert_cmpint(dst->type, =3D=3D, src->type); - g_assert(!dst->u.string.data); =20 - qapi_free_UserDefListUnion(src); - qapi_free_UserDefListUnion(dst); + g_assert_cmpint(dst->integer, =3D=3D, 123); + g_assert_cmpstr(dst->string, =3D=3D, "abc"); + g_assert_cmpint(dst->enum1, =3D=3D, ENUM_ONE_VALUE1); + g_assert(dst->u.value1.boolean); + g_assert(!dst->u.value1.has_a_b); + g_assert_cmpint(dst->u.value1.a_b, =3D=3D, 0); + + qapi_free_UserDefFlatUnion(src); + qapi_free_UserDefFlatUnion(dst); } =20 static void test_clone_complex2(void) --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539872879538.2430062161902; Mon, 13 Sep 2021 06:31:12 -0700 (PDT) Received: from localhost ([::1]:42492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm3D-0007ZL-O0 for importer@patchew.org; Mon, 13 Sep 2021 09:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFY-0000N9-S4 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000ig-Tg for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:52 -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-604-0FCJo2gsOkqnsibfdhODYw-1; Mon, 13 Sep 2021 08:39:43 -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 266A6802C80 for ; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B793C78433; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3E55911380B0; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=dmWPPAxcTcRJV93Ldwrxc3SDg9FSNOWP1YqtKzWXohc=; b=IYpy+NtkAKcJtXEMxyVCZlOy7ujFmm5we3BoZyGQn1iN9fi7z0Vzk81LkWEjeaRAjoPUF8 FMRtxp67MaWUeAv6PCT2Z8zEzm302GFQh9YJK5YrEpv3Jmp5DLR2IKSgjyKZu5VxgcDVDg Nx5WZlWIl/vPyGtEmyt7JL9CvjSRt1Q= X-MC-Unique: 0FCJo2gsOkqnsibfdhODYw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 15/22] tests/qapi-schema: Wean off UserDefListUnion Date: Mon, 13 Sep 2021 14:39:25 +0200 Message-Id: <20210913123932.3306639-16-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539873770100001 Content-Type: text/plain; charset="utf-8" Command boxed-union uses simple union UserDefListUnion to cover unions. Use UserDefFlatUnion instead. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-qmp-cmds.c | 2 +- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 83efa39720..83c9ef5b7c 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -119,7 +119,7 @@ void qmp_boxed_struct(UserDefZero *arg, Error **errp) { } =20 -void qmp_boxed_union(UserDefListUnion *arg, Error **errp) +void qmp_boxed_union(UserDefFlatUnion *arg, Error **errp) { } =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index b2d795cb19..a4b4405f94 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -175,7 +175,7 @@ 'returns': 'int' } { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } -{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true } +{ 'command': 'boxed-union', 'data': 'UserDefFlatUnion', 'boxed': true } { 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' } =20 # Smoke test on out-of-band and allow-preconfig-test diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 7a488c1d06..f120f10616 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -232,7 +232,7 @@ command guest-sync q_obj_guest-sync-arg -> any gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command boxed-struct UserDefZero -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse -command boxed-union UserDefListUnion -> None +command boxed-union UserDefFlatUnion -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse command boxed-empty Empty1 -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539407636370.87414960811975; Mon, 13 Sep 2021 06:23:27 -0700 (PDT) Received: from localhost ([::1]:53322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlvh-0003mN-W6 for importer@patchew.org; Mon, 13 Sep 2021 09:23:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFX-0000JJ-FI for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000ih-7L for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -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-604-Z2XnWB9AM1Wdc6qvecOVpQ-1; Mon, 13 Sep 2021 08:39:43 -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 EDF073FAB for ; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0B745B826; Mon, 13 Sep 2021 12:39:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 41B9D11380B7; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536784; 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=sOGm3nE7+0jj4zR5BlF4kcWQp7nINQMN8ak8dOR82r8=; b=MBr1+xQRm5QYmW9uc2W5tKUrKb28r8AXGN6gs5XsPRFvpr6sV69WYe64XFfzK29FcpB1OB ZADCLjtjCjkXkscLz2aSxfqATl6iE+uz9tg9WaJaGAH4ktRM3ncRDMy4xoKFi2M0Xr6bB5 hH0BFl0xj/flAlD04v2DTshrkTd4bbI= X-MC-Unique: Z2XnWB9AM1Wdc6qvecOVpQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 16/22] tests/qapi-schema: Simple union UserDefListUnion is now unused, drop Date: Mon, 13 Sep 2021 14:39:26 +0200 Message-Id: <20210913123932.3306639-17-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539409619100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 17 ------- tests/qapi-schema/qapi-schema-test.out | 64 ------------------------- 2 files changed, 81 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index a4b4405f94..eae43f41c4 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -123,23 +123,6 @@ # for testing use of 'str' within alternates { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } =20 -# for testing lists -{ 'union': 'UserDefListUnion', - 'data': { 'integer': ['int'], - 's8': ['int8'], - 's16': ['int16'], - 's32': ['int32'], - 's64': ['int64'], - 'u8': ['uint8'], - 'u16': ['uint16'], - 'u32': ['uint32'], - 'u64': ['uint64'], - 'number': ['number'], - 'boolean': ['bool'], - 'string': ['str'], - 'sizes': ['size'], - 'any': ['any'], - 'user': ['Status'] } } # intentional forward ref. to sub-module { 'struct': 'ArrayStruct', 'data': { 'integer': ['int'], 's8': ['int8'], diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index f120f10616..e43073d795 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -125,70 +125,6 @@ alternate AltStrObj tag type case s: str case o: TestStruct -object q_obj_intList-wrapper - member data: intList optional=3DFalse -object q_obj_int8List-wrapper - member data: int8List optional=3DFalse -object q_obj_int16List-wrapper - member data: int16List optional=3DFalse -object q_obj_int32List-wrapper - member data: int32List optional=3DFalse -object q_obj_int64List-wrapper - member data: int64List optional=3DFalse -object q_obj_uint8List-wrapper - member data: uint8List optional=3DFalse -object q_obj_uint16List-wrapper - member data: uint16List optional=3DFalse -object q_obj_uint32List-wrapper - member data: uint32List optional=3DFalse -object q_obj_uint64List-wrapper - member data: uint64List optional=3DFalse -object q_obj_numberList-wrapper - member data: numberList optional=3DFalse -object q_obj_boolList-wrapper - member data: boolList optional=3DFalse -object q_obj_strList-wrapper - member data: strList optional=3DFalse -object q_obj_sizeList-wrapper - member data: sizeList optional=3DFalse -object q_obj_anyList-wrapper - member data: anyList optional=3DFalse -object q_obj_StatusList-wrapper - member data: StatusList optional=3DFalse -enum UserDefListUnionKind - member integer - member s8 - member s16 - member s32 - member s64 - member u8 - member u16 - member u32 - member u64 - member number - member boolean - member string - member sizes - member any - member user -object UserDefListUnion - member type: UserDefListUnionKind optional=3DFalse - tag type - case integer: q_obj_intList-wrapper - case s8: q_obj_int8List-wrapper - case s16: q_obj_int16List-wrapper - case s32: q_obj_int32List-wrapper - case s64: q_obj_int64List-wrapper - case u8: q_obj_uint8List-wrapper - case u16: q_obj_uint16List-wrapper - case u32: q_obj_uint32List-wrapper - case u64: q_obj_uint64List-wrapper - case number: q_obj_numberList-wrapper - case boolean: q_obj_boolList-wrapper - case string: q_obj_strList-wrapper - case sizes: q_obj_sizeList-wrapper - case any: q_obj_anyList-wrapper - case user: q_obj_StatusList-wrapper object ArrayStruct member integer: intList optional=3DFalse member s8: int8List optional=3DFalse --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539685718636.231423344152; Mon, 13 Sep 2021 06:28:05 -0700 (PDT) Received: from localhost ([::1]:37026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm0C-0003UX-GI for importer@patchew.org; Mon, 13 Sep 2021 09:28:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFY-0000LH-0K for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFT-0000jD-Lf for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:51 -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-315---U91spUPFKYx0E1d2SJQQ-1; Mon, 13 Sep 2021 08:39:44 -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 C503C93C for ; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9758577F35; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 44F1E11380B9; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536785; 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=QmxzRf8YwTF05kblBr8hDdHUFEA3kja80XGlFQDQ7ts=; b=bxEOirF4pV7mnxWKvjA4ZogGsps0EQFxVGJnRKlKf0qgC+6CnByjWVE10nYnapkOk1cp3K y0rS80uG4zNQHgTO/qXL82wf58KaI8WWSffduAGyhCDq4OK6tTqFCqcftBjoKEABLOU8/k s2wF9K+Ex73+WIWfR+QVzaEBB2ikMQE= X-MC-Unique: --U91spUPFKYx0E1d2SJQQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 17/22] tests/qapi-schema: Rewrite simple union TestIfUnion to be flat Date: Mon, 13 Sep 2021 14:39:27 +0200 Message-Id: <20210913123932.3306639-18-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539686221100001 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. To prepare for their removal, rewrite TestIfUnion to be flat. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/qapi-schema/qapi-schema-test.json | 4 +++- tests/qapi-schema/qapi-schema-test.out | 16 ++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index eae43f41c4..ef17ab1aae 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -229,8 +229,10 @@ 'if': 'TEST_IF_ENUM' } =20 { 'union': 'TestIfUnion', + 'base': { 'type': 'TestIfEnum' }, + 'discriminator': 'type', 'data': { 'foo': 'TestStruct', - 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} }, + 'bar': { 'type': 'UserDefZero', 'if': 'TEST_IF_ENUM_BAR'} }, 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } } =20 { 'command': 'test-if-union-cmd', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e43073d795..07e4161331 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -257,19 +257,15 @@ enum TestIfEnum member bar 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 TEST_IF_UNION_BAR +object q_obj_TestIfUnion-base + member type: TestIfEnum optional=3DFalse if {'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT']} object TestIfUnion - member type: TestIfUnionKind optional=3DFalse + base q_obj_TestIfUnion-base tag type - case foo: q_obj_TestStruct-wrapper - case bar: q_obj_str-wrapper - if TEST_IF_UNION_BAR + case foo: TestStruct + case bar: UserDefZero + if TEST_IF_ENUM_BAR if {'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT']} object q_obj_test-if-union-cmd-arg member union-cmd-arg: TestIfUnion optional=3DFalse --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 163154024467664.37504729317197; Mon, 13 Sep 2021 06:37:24 -0700 (PDT) Received: from localhost ([::1]:57252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm9D-0000kj-Eh for importer@patchew.org; Mon, 13 Sep 2021 09:37:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFf-0000Vu-Vu for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:40:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFe-0000r8-DM for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:59 -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-572-lSI1SwCCOj6FUxJzuMSSEg-1; Mon, 13 Sep 2021 08:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A552319200C3 for ; Mon, 13 Sep 2021 12:39:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A21941037E99; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 48DE111380BC; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536797; 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=gdPR75eYbQXxD0iOTPV5eI2d97+ye2PZP2RByIGD8WM=; b=AN71KT70z4Q5Z3TP5JT3hcZKFUK6DQQQ6XdSYJc0C+oyBIFX8nTlpJK4akJD5LBAgSzDyc J10mC+5sT6i2FvRznieUpsO9k6wDu37TEA6Vor6OqA4RQ/kYXHWJxQgimvlONY6zjV6tBo CkavuSsvZ83XrXU3OicHUSEhZDa38ew= X-MC-Unique: lSI1SwCCOj6FUxJzuMSSEg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 18/22] test-clone-visitor: Wean off __org.qemu_x-Union1 Date: Mon, 13 Sep 2021 14:39:28 +0200 Message-Id: <20210913123932.3306639-19-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631540246729100001 Content-Type: text/plain; charset="utf-8" test_clone_complex3() uses simple union __org.qemu_x-Union1 to cover arrays. Use UserDefOneList instead. Unions are still covered by test_clone_complex1(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-clone-visitor.c | 70 ++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 8357a90e60..4048018607 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -153,42 +153,48 @@ static void test_clone_complex2(void) =20 static void test_clone_complex3(void) { - __org_qemu_x_Struct2 *src, *dst; - __org_qemu_x_Union1List *tmp; + UserDefOneList *src, *dst, *tail; + UserDefOne *elt; =20 - src =3D g_new0(__org_qemu_x_Struct2, 1); - tmp =3D src->array =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("one"); - tmp =3D tmp->next =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("two"); - tmp =3D tmp->next =3D g_new0(__org_qemu_x_Union1List, 1); - tmp->value =3D g_new0(__org_qemu_x_Union1, 1); - tmp->value->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - tmp->value->u.__org_qemu_x_branch.data =3D g_strdup("three"); + src =3D NULL; + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 3; + elt->string =3D g_strdup("three"); + elt->has_enum1 =3D true; + elt->enum1 =3D ENUM_ONE_VALUE3; + QAPI_LIST_PREPEND(src, elt); + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 2; + elt->string =3D g_strdup("two"); + QAPI_LIST_PREPEND(src, elt); + elt =3D g_new0(UserDefOne, 1); + elt->integer =3D 1; + elt->string =3D g_strdup("one"); + QAPI_LIST_PREPEND(src, elt); + + dst =3D QAPI_CLONE(UserDefOneList, src); =20 - dst =3D QAPI_CLONE(__org_qemu_x_Struct2, src); g_assert(dst); - tmp =3D dst->array; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "one"); - tmp =3D tmp->next; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "two"); - tmp =3D tmp->next; - g_assert(tmp); - g_assert(tmp->value); - g_assert_cmpstr(tmp->value->u.__org_qemu_x_branch.data, =3D=3D, "three= "); - tmp =3D tmp->next; - g_assert(!tmp); + tail =3D dst; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 1); + g_assert_cmpstr(elt->string, =3D=3D, "one"); + g_assert(!elt->has_enum1); + tail =3D tail->next; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 2); + g_assert_cmpstr(elt->string, =3D=3D, "two"); + g_assert(!elt->has_enum1); + tail =3D tail->next; + elt =3D tail->value; + g_assert_cmpint(elt->integer, =3D=3D, 3); + g_assert_cmpstr(elt->string, =3D=3D, "three"); + g_assert(elt->has_enum1); + g_assert_cmpint(elt->enum1, =3D=3D, ENUM_ONE_VALUE3); + g_assert(!tail->next); =20 - qapi_free___org_qemu_x_Struct2(src); - qapi_free___org_qemu_x_Struct2(dst); + qapi_free_UserDefOneList(src); + qapi_free_UserDefOneList(dst); } =20 int main(int argc, char **argv) --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631540286719638.2923369259779; Mon, 13 Sep 2021 06:38:06 -0700 (PDT) Received: from localhost ([::1]:59730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPm9t-0002Rb-OP for importer@patchew.org; Mon, 13 Sep 2021 09:38:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFa-0000SD-Jd for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000jN-VU for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-584-RIU3bS2VPqi7zjmjCXbv1g-1; Mon, 13 Sep 2021 08:39:44 -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 28D7D1084684 for ; Mon, 13 Sep 2021 12:39:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C95075F706; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4C3FD11380CC; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536786; 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=WkMIz7ZCVk0gOO4Dq3HTK1PkcZrxSntb56NFVQs/vig=; b=T266c9s4rd9s3aDYwk/FZd0+SMEhPVFtt47ejESEHEMJVd9ZhfHib/2KAgtUiCKXzNY8i2 +m1SdRuI7b8GoAV5vQh7dNlP78yGwEtFWQW2y0hIHg5gcTClkHPV7gtg/yjHDHj5m+oY9s Ep8nsjrpGXAQUrxbMXkK8Aa/9GoX8IY= X-MC-Unique: RIU3bS2VPqi7zjmjCXbv1g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 19/22] tests/qapi-schema: Drop simple union __org.qemu_x-Union1 Date: Mon, 13 Sep 2021 14:39:29 +0200 Message-Id: <20210913123932.3306639-20-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631540288706100001 Content-Type: text/plain; charset="utf-8" Replace simple union __org.qemu_x-Union1 flat union __org.qemu_x-Union2, except drop it from __org.qemu_x-command, because there it's only used to pull it into QMP. Now drop the unused simple union. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-qmp-cmds.c | 16 +++++----------- tests/qapi-schema/qapi-schema-test.json | 6 ++---- tests/qapi-schema/qapi-schema-test.out | 14 +++----------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 83c9ef5b7c..a43b97d6c5 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -127,22 +127,16 @@ void qmp_boxed_empty(Empty1 *arg, Error **errp) { } =20 -__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, - __org_qemu_x_StructList *b, - __org_qemu_x_Union2 *c, - __org_qemu_x_Alt *d, - Error **errp) +void qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, + __org_qemu_x_StructList *b, + __org_qemu_x_Union2 *c, + __org_qemu_x_Alt *d, + Error **errp) { - __org_qemu_x_Union1 *ret =3D g_new0(__org_qemu_x_Union1, 1); - - ret->type =3D ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; - ret->u.__org_qemu_x_branch.data =3D strdup("blah1"); - /* Also test that 'wchar-t' was munged to 'q_wchar_t' */ if (b && b->value && !b->value->has_q_wchar_t) { b->value->q_wchar_t =3D 1; } - return ret; } =20 =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index ef17ab1aae..0c19d4820e 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -202,10 +202,9 @@ 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } } { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base', 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } } -{ 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' }= } { 'alternate': '__org.qemu_x-Alt1', 'data': { '__org.qemu_x-branch': 'str'= } } { 'struct': '__org.qemu_x-Struct2', - 'data': { 'array': ['__org.qemu_x-Union1'] } } + 'data': { 'array': ['__org.qemu_x-Union2'] } } { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base', 'discriminator': '__org.qemu_x-member1', 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } } @@ -214,8 +213,7 @@ { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' } { 'command': '__org.qemu_x-command', 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'], - 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' }, - 'returns': '__org.qemu_x-Union1' } + 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' } } =20 # test 'if' condition handling =20 diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 07e4161331..0b49dc3044 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -215,20 +215,12 @@ object __org.qemu_x-Struct base __org.qemu_x-Base member __org.qemu_x-member2: str optional=3DFalse member wchar-t: int optional=3DTrue -object q_obj_str-wrapper - member data: str optional=3DFalse -enum __org.qemu_x-Union1Kind - member __org.qemu_x-branch -object __org.qemu_x-Union1 - member type: __org.qemu_x-Union1Kind optional=3DFalse - tag type - case __org.qemu_x-branch: q_obj_str-wrapper alternate __org.qemu_x-Alt1 tag type case __org.qemu_x-branch: str -array __org.qemu_x-Union1List __org.qemu_x-Union1 +array __org.qemu_x-Union2List __org.qemu_x-Union2 object __org.qemu_x-Struct2 - member array: __org.qemu_x-Union1List optional=3DFalse + member array: __org.qemu_x-Union2List optional=3DFalse object __org.qemu_x-Union2 base __org.qemu_x-Base tag __org.qemu_x-member1 @@ -245,7 +237,7 @@ object q_obj___org.qemu_x-command-arg member b: __org.qemu_x-StructList optional=3DFalse member c: __org.qemu_x-Union2 optional=3DFalse member d: __org.qemu_x-Alt optional=3DFalse -command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 +command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object TestIfStruct member foo: int optional=3DFalse --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631540476100210.46053077646445; Mon, 13 Sep 2021 06:41:16 -0700 (PDT) Received: from localhost ([::1]:40056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPmCw-00086k-LL for importer@patchew.org; Mon, 13 Sep 2021 09:41:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFc-0000Sa-5n for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFV-0000jd-12 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-122-lqc2i7fhPuy_AOgkhcRFZA-1; Mon, 13 Sep 2021 08:39:45 -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 5A64780006E for ; Mon, 13 Sep 2021 12:39:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4D825D9CA; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4FC8211380D0; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536786; 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=Lv2S7KscXdOTESDcY4Ql+nkRxpdCaDGlJx8vGnsfLiM=; b=Znc5yhOpC1i/YMLnTOLEmJLSxtq5PKjfVbOlyla+p5xbtan34zsUj7G/JWwGHuKjWS6Byd lEnbnb3FSw49qWkzQzYCn7l3nzQUYVDIAZWU+3O6PQZ+8KD/Pc3MQ53q7acWjlaTSYymIg G4aSmQFm2ge0ev/H/z1QiIFiBOQTnYk= X-MC-Unique: lqc2i7fhPuy_AOgkhcRFZA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 20/22] tests/qapi-schema: Purge simple unions from tests Date: Mon, 13 Sep 2021 14:39:30 +0200 Message-Id: <20210913123932.3306639-21-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631540477070100003 Content-Type: text/plain; charset="utf-8" Drop tests that are specifically about simple unions: * SugaredUnion in doc-good: flat unions are covered by @Object. * union-branch-case and union-clash-branches: branch naming for flat unions is enforced for the tag enum instead, which is covered by enum-member-case and enum-clash-member. * union-empty: empty flat unions are covered by flat-union-empty. Rewrite the remainder to use flat unions: args-union, bad-base, flat-union-base-union, union-branch-invalid-dict, union-unknown. Except drop union-optional-branch. because converting this one is not worth the trouble; we don't explicitly check names beginning with '*' in other places, either. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/qapi-schema/args-union.err | 2 +- tests/qapi-schema/args-union.json | 8 ++++++- tests/qapi-schema/bad-base.err | 2 +- tests/qapi-schema/bad-base.json | 8 ++++++- tests/qapi-schema/doc-good.json | 9 -------- tests/qapi-schema/doc-good.out | 22 ------------------- tests/qapi-schema/doc-good.txt | 20 ----------------- tests/qapi-schema/flat-union-base-union.err | 2 +- tests/qapi-schema/flat-union-base-union.json | 3 +++ tests/qapi-schema/meson.build | 4 ---- tests/qapi-schema/union-branch-case.err | 2 -- tests/qapi-schema/union-branch-case.json | 2 -- tests/qapi-schema/union-branch-case.out | 0 .../qapi-schema/union-branch-invalid-dict.err | 2 +- .../union-branch-invalid-dict.json | 4 ++++ tests/qapi-schema/union-clash-branches.err | 2 -- tests/qapi-schema/union-clash-branches.json | 7 ------ tests/qapi-schema/union-clash-branches.out | 0 tests/qapi-schema/union-empty.err | 2 -- tests/qapi-schema/union-empty.json | 2 -- tests/qapi-schema/union-empty.out | 0 tests/qapi-schema/union-optional-branch.err | 2 -- tests/qapi-schema/union-optional-branch.json | 2 -- tests/qapi-schema/union-optional-branch.out | 0 tests/qapi-schema/union-unknown.err | 2 +- tests/qapi-schema/union-unknown.json | 5 ++++- 26 files changed, 30 insertions(+), 84 deletions(-) delete mode 100644 tests/qapi-schema/union-branch-case.err delete mode 100644 tests/qapi-schema/union-branch-case.json delete mode 100644 tests/qapi-schema/union-branch-case.out delete mode 100644 tests/qapi-schema/union-clash-branches.err delete mode 100644 tests/qapi-schema/union-clash-branches.json delete mode 100644 tests/qapi-schema/union-clash-branches.out delete mode 100644 tests/qapi-schema/union-empty.err delete mode 100644 tests/qapi-schema/union-empty.json delete mode 100644 tests/qapi-schema/union-empty.out delete mode 100644 tests/qapi-schema/union-optional-branch.err delete mode 100644 tests/qapi-schema/union-optional-branch.json delete mode 100644 tests/qapi-schema/union-optional-branch.out diff --git a/tests/qapi-schema/args-union.err b/tests/qapi-schema/args-unio= n.err index 4bf4955027..4b80a99f74 100644 --- a/tests/qapi-schema/args-union.err +++ b/tests/qapi-schema/args-union.err @@ -1,2 +1,2 @@ args-union.json: In command 'oops': -args-union.json:3: command's 'data' can take union type 'Uni' only with 'b= oxed': true +args-union.json:9: command's 'data' can take union type 'Uni' only with 'b= oxed': true diff --git a/tests/qapi-schema/args-union.json b/tests/qapi-schema/args-uni= on.json index 2fcaeaae16..aabb159063 100644 --- a/tests/qapi-schema/args-union.json +++ b/tests/qapi-schema/args-union.json @@ -1,3 +1,9 @@ # use of union arguments requires 'boxed':true -{ 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } +{ 'enum': 'Enum', 'data': [ 'case1', 'case2' ] } +{ 'struct': 'Case1', 'data': { 'data': 'int' } } +{ 'struct': 'Case2', 'data': { 'data': 'str' } } +{ 'union': 'Uni', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'case1': 'Case1', 'case2': 'Case2' } } { 'command': 'oops', 'data': 'Uni' } diff --git a/tests/qapi-schema/bad-base.err b/tests/qapi-schema/bad-base.err index 61a1efc2c0..1fad63e392 100644 --- a/tests/qapi-schema/bad-base.err +++ b/tests/qapi-schema/bad-base.err @@ -1,2 +1,2 @@ bad-base.json: In struct 'MyType': -bad-base.json:3: 'base' requires a struct type, union type 'Union' isn't +bad-base.json:9: 'base' requires a struct type, union type 'Union' isn't diff --git a/tests/qapi-schema/bad-base.json b/tests/qapi-schema/bad-base.j= son index a634331cdd..8c773ff544 100644 --- a/tests/qapi-schema/bad-base.json +++ b/tests/qapi-schema/bad-base.json @@ -1,3 +1,9 @@ # we reject a base that is not a struct -{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } } +{ 'enum': 'Enum', 'data': [ 'a', 'b' ] } +{ 'struct': 'Int', 'data': { 'data': 'int' } } +{ 'struct': 'Str', 'data': { 'data': 'str' } } +{ 'union': 'Union', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'a': 'Int', 'b': 'Str' } } { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } } diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index cbf5c56c4b..a20acffd8b 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -107,15 +107,6 @@ 'two': { 'type': 'Variant2', 'if': { 'any': ['IFONE', 'IFTWO'] } } } } =20 -## -# @SugaredUnion: -# Features: -# @union-feat2: a feature -## -{ 'union': 'SugaredUnion', - 'features': [ 'union-feat2' ], - 'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' = } } } - ## # @Alternate: # @i: an integer diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 478fe6f82e..5a324e2627 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -32,21 +32,6 @@ object Object case two: Variant2 if {'any': ['IFONE', 'IFTWO']} feature union-feat1 -object q_obj_Variant1-wrapper - member data: Variant1 optional=3DFalse -object q_obj_Variant2-wrapper - member data: Variant2 optional=3DFalse -enum SugaredUnionKind - member one - member two - 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 - feature union-feat2 alternate Alternate tag type case i: int @@ -149,13 +134,6 @@ doc symbol=3DObject =20 feature=3Dunion-feat1 a feature -doc symbol=3DSugaredUnion - body=3D - - arg=3Dtype - - feature=3Dunion-feat2 -a feature doc symbol=3DAlternate body=3D =20 diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 0c59d75964..701402ee5e 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -130,26 +130,6 @@ Features a feature =20 =20 -"SugaredUnion" (Object) ------------------------ - - -Members -~~~~~~~ - -"type" - One of "one", "two" - -"data": "Variant1" when "type" is ""one"" -"data": "Variant2" when "type" is ""two"" (**If: **"IFTWO") - -Features -~~~~~~~~ - -"union-feat2" - a feature - - "Alternate" (Alternate) ----------------------- =20 diff --git a/tests/qapi-schema/flat-union-base-union.err b/tests/qapi-schem= a/flat-union-base-union.err index 3b0087220e..3563e8777e 100644 --- a/tests/qapi-schema/flat-union-base-union.err +++ b/tests/qapi-schema/flat-union-base-union.err @@ -1,2 +1,2 @@ flat-union-base-union.json: In union 'TestUnion': -flat-union-base-union.json:14: 'base' requires a struct type, union type '= UnionBase' isn't +flat-union-base-union.json:17: 'base' requires a struct type, union type '= UnionBase' isn't diff --git a/tests/qapi-schema/flat-union-base-union.json b/tests/qapi-sche= ma/flat-union-base-union.json index 98b4eba181..82d4c96e57 100644 --- a/tests/qapi-schema/flat-union-base-union.json +++ b/tests/qapi-schema/flat-union-base-union.json @@ -8,7 +8,10 @@ 'data': { 'string': 'str' } } { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +{ 'enum': 'Enum', 'data': [ 'kind1', 'kind2' ] } { 'union': 'UnionBase', + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', 'data': { 'kind1': 'TestTypeA', 'kind2': 'TestTypeB' } } { 'union': 'TestUnion', diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 0798e94042..85d3de1481 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -192,14 +192,10 @@ schemas =3D [ 'unclosed-string.json', 'union-base-empty.json', 'union-base-no-discriminator.json', - 'union-branch-case.json', 'union-branch-if-invalid.json', 'union-branch-invalid-dict.json', - 'union-clash-branches.json', - 'union-empty.json', 'union-invalid-base.json', 'union-invalid-data.json', - 'union-optional-branch.json', 'union-unknown.json', 'unknown-escape.json', 'unknown-expr-key.json', diff --git a/tests/qapi-schema/union-branch-case.err b/tests/qapi-schema/un= ion-branch-case.err deleted file mode 100644 index d2d5cb8993..0000000000 --- a/tests/qapi-schema/union-branch-case.err +++ /dev/null @@ -1,2 +0,0 @@ -union-branch-case.json: In union 'Uni': -union-branch-case.json:2: name of 'data' member 'Branch' must not use uppe= rcase or '_' diff --git a/tests/qapi-schema/union-branch-case.json b/tests/qapi-schema/u= nion-branch-case.json deleted file mode 100644 index b7894b75d6..0000000000 --- a/tests/qapi-schema/union-branch-case.json +++ /dev/null @@ -1,2 +0,0 @@ -# Branch names should be 'lower-case' -{ 'union': 'Uni', 'data': { 'Branch': 'int' } } diff --git a/tests/qapi-schema/union-branch-case.out b/tests/qapi-schema/un= ion-branch-case.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-branch-invalid-dict.err b/tests/qapi-s= chema/union-branch-invalid-dict.err index 8137c5a767..001cdec069 100644 --- a/tests/qapi-schema/union-branch-invalid-dict.err +++ b/tests/qapi-schema/union-branch-invalid-dict.err @@ -1,2 +1,2 @@ union-branch-invalid-dict.json: In union 'UnionInvalidBranch': -union-branch-invalid-dict.json:2: 'data' member 'integer' misses key 'type' +union-branch-invalid-dict.json:4: 'data' member 'integer' misses key 'type' diff --git a/tests/qapi-schema/union-branch-invalid-dict.json b/tests/qapi-= schema/union-branch-invalid-dict.json index 9778598dbd..c7c81c0e00 100644 --- a/tests/qapi-schema/union-branch-invalid-dict.json +++ b/tests/qapi-schema/union-branch-invalid-dict.json @@ -1,4 +1,8 @@ # Long form of member must have a value member 'type' +{ 'enum': 'TestEnum', + 'data': [ 'integer', 's8' ] } { 'union': 'UnionInvalidBranch', + 'base': { 'type': 'TestEnum' }, + 'discriminator': 'type', 'data': { 'integer': { 'if': 'foo'}, 's8': 'int8' } } diff --git a/tests/qapi-schema/union-clash-branches.err b/tests/qapi-schema= /union-clash-branches.err deleted file mode 100644 index ef53645728..0000000000 --- a/tests/qapi-schema/union-clash-branches.err +++ /dev/null @@ -1,2 +0,0 @@ -union-clash-branches.json: In union 'TestUnion': -union-clash-branches.json:6: name of 'data' member 'a_b' must not use uppe= rcase or '_' diff --git a/tests/qapi-schema/union-clash-branches.json b/tests/qapi-schem= a/union-clash-branches.json deleted file mode 100644 index 7bdda0b0da..0000000000 --- a/tests/qapi-schema/union-clash-branches.json +++ /dev/null @@ -1,7 +0,0 @@ -# Union branch name collision -# Naming rules make collision impossible (even with the pragma). If -# that wasn't the case, then we'd get collisions in generated C: two -# union members a_b, and two enum members TEST_UNION_A_B. -{ 'pragma': { 'member-name-exceptions': [ 'TestUnion' ] } } -{ 'union': 'TestUnion', - 'data': { 'a-b': 'int', 'a_b': 'str' } } diff --git a/tests/qapi-schema/union-clash-branches.out b/tests/qapi-schema= /union-clash-branches.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-empty.err b/tests/qapi-schema/union-em= pty.err deleted file mode 100644 index 59788c94ce..0000000000 --- a/tests/qapi-schema/union-empty.err +++ /dev/null @@ -1,2 +0,0 @@ -union-empty.json: In union 'Union': -union-empty.json:2: union has no branches diff --git a/tests/qapi-schema/union-empty.json b/tests/qapi-schema/union-e= mpty.json deleted file mode 100644 index df3e5e639a..0000000000 --- a/tests/qapi-schema/union-empty.json +++ /dev/null @@ -1,2 +0,0 @@ -# simple unions cannot be empty -{ 'union': 'Union', 'data': { } } diff --git a/tests/qapi-schema/union-empty.out b/tests/qapi-schema/union-em= pty.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-optional-branch.err b/tests/qapi-schem= a/union-optional-branch.err deleted file mode 100644 index b33f111de4..0000000000 --- a/tests/qapi-schema/union-optional-branch.err +++ /dev/null @@ -1,2 +0,0 @@ -union-optional-branch.json: In union 'Union': -union-optional-branch.json:2: 'data' member '*a' has an invalid name diff --git a/tests/qapi-schema/union-optional-branch.json b/tests/qapi-sche= ma/union-optional-branch.json deleted file mode 100644 index 591615fc68..0000000000 --- a/tests/qapi-schema/union-optional-branch.json +++ /dev/null @@ -1,2 +0,0 @@ -# union branches cannot be optional -{ 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } } diff --git a/tests/qapi-schema/union-optional-branch.out b/tests/qapi-schem= a/union-optional-branch.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/union-unknown.err b/tests/qapi-schema/union-= unknown.err index 7aba9f94da..dad79beae0 100644 --- a/tests/qapi-schema/union-unknown.err +++ b/tests/qapi-schema/union-unknown.err @@ -1,2 +1,2 @@ union-unknown.json: In union 'Union': -union-unknown.json:2: union uses unknown type 'MissingType' +union-unknown.json:3: branch 'unknown' uses unknown type 'MissingType' diff --git a/tests/qapi-schema/union-unknown.json b/tests/qapi-schema/union= -unknown.json index 64d3666176..4736f1ab08 100644 --- a/tests/qapi-schema/union-unknown.json +++ b/tests/qapi-schema/union-unknown.json @@ -1,3 +1,6 @@ # we reject a union with unknown type in branch +{ 'enum': 'Enum', 'data': [ 'unknown' ] } { 'union': 'Union', - 'data': { 'unknown': ['MissingType'] } } + 'base': { 'type': 'Enum' }, + 'discriminator': 'type', + 'data': { 'unknown': 'MissingType' } } --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631539369353860.1902347816131; Mon, 13 Sep 2021 06:22:49 -0700 (PDT) Received: from localhost ([::1]:51570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlv5-0002bz-VF for importer@patchew.org; Mon, 13 Sep 2021 09:22:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFd-0000Ul-ER for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFZ-0000nn-6h for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:57 -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-73-n3euxnI2PjSCx94TdXFzoA-1; Mon, 13 Sep 2021 08:39:45 -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 6B15780196C for ; Mon, 13 Sep 2021 12:39:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFDBE16A31; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 53B0811380D5; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536792; 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=DGVBPxlJ6W6fvASUA0bPYFglyidwC/oGDvEWPmWw8W0=; b=Sq4jSWxPpncU+5BOuWcEXLXmkARl4FbbBFwoda34j5OS7Q3VOErkUymK2ELC7NvssalWuR EpPQ286/SI0DKqJBRiXxLBawDg1vlMJh/6bR/btKHn/3dbzUUeJjQ/r3HajmNmIB48NU9S NdGAFamDblGwUQU0HsHnSBQzUdETrMg= X-MC-Unique: n3euxnI2PjSCx94TdXFzoA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 21/22] qapi: Drop simple unions Date: Mon, 13 Sep 2021 14:39:31 +0200 Message-Id: <20210913123932.3306639-22-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631539370130100003 Content-Type: text/plain; charset="utf-8" Simple unions predate flat unions. Having both complicates the QAPI schema language and the QAPI generator. We haven't been using simple unions in new code for a long time, because they are less flexible and somewhat awkward on the wire. The previous commits eliminated simple union from the tree. Now drop them from the QAPI schema language entirely, and update mentions of "flat union" to just "union". Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.rst | 125 ++++-------------- scripts/qapi/expr.py | 21 +-- scripts/qapi/schema.py | 101 +++----------- .../qapi-schema/flat-union-array-branch.json | 2 +- tests/qapi-schema/flat-union-empty.json | 2 +- tests/qapi-schema/flat-union-int-branch.json | 2 +- tests/qapi-schema/flat-union-no-base.err | 2 +- tests/qapi-schema/flat-union-no-base.json | 2 +- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/reserved-member-u.json | 2 +- tests/qapi-schema/union-base-empty.json | 2 +- .../union-base-no-discriminator.err | 2 +- .../union-base-no-discriminator.json | 2 +- 13 files changed, 62 insertions(+), 205 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index b154eae82e..b2569de486 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -319,13 +319,9 @@ Union types Syntax:: =20 UNION =3D { 'union': STRING, - 'data': BRANCHES, - '*if': COND, - '*features': FEATURES } - | { 'union': STRING, - 'data': BRANCHES, 'base': ( MEMBERS | STRING ), 'discriminator': STRING, + 'data': BRANCHES, '*if': COND, '*features': FEATURES } BRANCHES =3D { BRANCH, ... } @@ -334,63 +330,30 @@ Syntax:: =20 Member 'union' names the union type. =20 -There are two flavors of union types: simple (no discriminator or -base), and flat (both discriminator and base). - -Each BRANCH of the 'data' object defines a branch of the union. A -union must have at least one branch. - -The BRANCH's STRING name is the branch name. - -The BRANCH's value defines the branch's properties, in particular its -type. The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`. - -A simple union type defines a mapping from automatic discriminator -values to data types like in this example:: - - { 'struct': 'BlockdevOptionsFile', 'data': { 'filename': 'str' } } - { 'struct': 'BlockdevOptionsQcow2', - 'data': { 'backing': 'str', '*lazy-refcounts': 'bool' } } - - { 'union': 'BlockdevOptionsSimple', - 'data': { 'file': 'BlockdevOptionsFile', - 'qcow2': 'BlockdevOptionsQcow2' } } - -In the Client JSON Protocol, a simple union is represented by an -object that contains the 'type' member as a discriminator, and a -'data' member that is of the specified data type corresponding to the -discriminator value, as in these examples:: - - { "type": "file", "data": { "filename": "/some/place/my-image" } } - { "type": "qcow2", "data": { "backing": "/some/place/my-image", - "lazy-refcounts": true } } - -The generated C code uses a struct containing a union. Additionally, -an implicit C enum 'NameKind' is created, corresponding to the union -'Name', for accessing the various branches of the union. The value -for each branch can be of any type. - -Flat unions permit arbitrary common members that occur in all variants -of the union, not just a discriminator. Their discriminators need not -be named 'type'. They also avoid nesting on the wire. - The 'base' member defines the common members. If it is a MEMBERS_ object, it defines common members just like a struct type's 'data' member defines struct type members. If it is a STRING, it names a struct type whose members are the common members. =20 -All flat union branches must be `Struct types`_. +Member 'discriminator' must name a non-optional enum-typed member of +the base struct. That member's value selects a branch by its name. +If no such branch exists, an empty branch is assumed. =20 -In the Client JSON Protocol, a flat union is represented by an object -with the common members (from the base type) and the selected branch's -members. The two sets of member names must be disjoint. Member -'discriminator' must name a non-optional enum-typed member of the base -struct. +Each BRANCH of the 'data' object defines a branch of the union. A +union must have at least one branch. =20 -The following example enhances the above simple union example by -adding an optional common member 'read-only', renaming the -discriminator to something more applicable than the simple union's -default of 'type', and reducing the number of ``{}`` required on the wire:: +The BRANCH's STRING name is the branch name. It must be a value of +the discriminator enum type. + +The BRANCH's value defines the branch's properties, in particular its +type. The type must a struct type. The form TYPE-REF_ is shorthand +for :code:`{ 'type': TYPE-REF }`. + +In the Client JSON Protocol, a union is represented by an object with +the common members (from the base type) and the selected branch's +members. The two sets of member names must be disjoint. + +Example:: =20 { 'enum': 'BlockdevDriver', 'data': [ 'file', 'qcow2' ] } { 'union': 'BlockdevOptions', @@ -406,30 +369,11 @@ Resulting in these JSON objects:: { "driver": "qcow2", "read-only": false, "backing": "/some/place/my-image", "lazy-refcounts": true } =20 -Notice that in a flat union, the discriminator name is controlled by -the user, but because it must map to a base member with enum type, the -code generator ensures that branches match the existing values of the -enum. The order of branches need not match the order of the enum -values. The branches need not cover all possible enum values. -Omitted enum values are still valid branches that add no additional -members to the data type. In the resulting generated C data types, a -flat union is represented as a struct with the base members in QAPI -schema order, and then a union of structures for each branch of the -struct. - -A simple union can always be re-written as a flat union where the base -class has a single member named 'type', and where each branch of the -union has a struct with a single member named 'data'. That is, :: - - { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } } - -is identical on the wire to:: - - { 'enum': 'Enum', 'data': ['one', 'two'] } - { 'struct': 'Branch1', 'data': { 'data': 'str' } } - { 'struct': 'Branch2', 'data': { 'data': 'int' } } - { 'union': 'Flat', 'base': { 'type': 'Enum' }, 'discriminator': 'type', - 'data': { 'one': 'Branch1', 'two': 'Branch2' } } +The order of branches need not match the order of the enum values. +The branches need not cover all possible enum values. In the +resulting generated C data types, a union is represented as a struct +with the base members in QAPI schema order, and then a union of +structures for each branch of the struct. =20 The optional 'if' member specifies a conditional. See `Configuring the schema`_ below for more on this. @@ -1246,7 +1190,7 @@ that provides the variant members for this type tag v= alue). The "variants" array is in no particular order, and is not guaranteed to list cases in the same order as the corresponding "tag" enum type. =20 -Example: the SchemaInfo for flat union BlockdevOptions from section +Example: the SchemaInfo for union BlockdevOptions from section `Union types`_ :: =20 { "name": "BlockdevOptions", "meta-type": "object", @@ -1261,27 +1205,6 @@ Example: the SchemaInfo for flat union BlockdevOptio= ns from section Note that base types are "flattened": its members are included in the "members" array. =20 -A simple union implicitly defines an enumeration type for its implicit -discriminator (called "type" on the wire, see section `Union types`_). - -A simple union implicitly defines an object type for each of its -variants. - -Example: the SchemaInfo for simple union BlockdevOptionsSimple from section -`Union types`_ :: - - { "name": "BlockdevOptionsSimple", "meta-type": "object", - "members": [ - { "name": "type", "type": "BlockdevOptionsSimpleKind" } ], - "tag": "type", - "variants": [ - { "case": "file", "type": "q_obj-BlockdevOptionsFile-wrapper" }, - { "case": "qcow2", "type": "q_obj-BlockdevOptionsQcow2-wrapper" = } ] } - - Enumeration type "BlockdevOptionsSimpleKind" and the object types - "q_obj-BlockdevOptionsFile-wrapper", "q_obj-BlockdevOptionsQcow2-wrapp= er" - are implicitly defined. - The SchemaInfo for an alternate type has meta-type "alternate", and variant member "members". "members" is a JSON array. Each element is a JSON object with member "type", which names a type. Values of the diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 91959ee79a..819ea6ad97 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -513,27 +513,18 @@ def check_union(expr: _JSONObject, info: QAPISourceIn= fo) -> None: :return: None, ``expr`` is normalized in-place as needed. """ name =3D cast(str, expr['union']) # Checked in check_exprs - base =3D expr.get('base') - discriminator =3D expr.get('discriminator') + base =3D expr['base'] + discriminator =3D expr['discriminator'] members =3D expr['data'] =20 - if discriminator is None: # simple union - if base is not None: - raise QAPISemError(info, "'base' requires 'discriminator'") - else: # flat union - check_type(base, info, "'base'", allow_dict=3Dname) - if not base: - raise QAPISemError(info, "'discriminator' requires 'base'") - check_name_is_str(discriminator, info, "'discriminator'") + check_type(base, info, "'base'", allow_dict=3Dname) + check_name_is_str(discriminator, info, "'discriminator'") =20 if not isinstance(members, dict): raise QAPISemError(info, "'data' must be an object") =20 for (key, value) in members.items(): source =3D "'data' member '%s'" % key - if discriminator is None: - check_name_lower(key, info, source) - # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source, allow_array=3Dnot base) @@ -664,8 +655,8 @@ def check_exprs(exprs: List[_JSONObject]) -> List[_JSON= Object]: check_enum(expr, info) elif meta =3D=3D 'union': check_keys(expr, info, meta, - ['union', 'data'], - ['base', 'discriminator', 'if', 'features']) + ['union', 'base', 'discriminator', 'data'], + ['if', 'features']) normalize_members(expr.get('base')) normalize_members(expr['data']) check_union(expr, info) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3d72c7dfc9..004d7095ff 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -321,8 +321,8 @@ def connect_doc(self, doc=3DNone): m.connect_doc(doc) =20 def is_implicit(self): - # See QAPISchema._make_implicit_enum_type() and ._def_predefineds() - return self.name.endswith('Kind') or self.name =3D=3D 'QType' + # See QAPISchema._def_predefineds() + return self.name =3D=3D 'QType' =20 def c_type(self): return c_name(self.name) @@ -393,8 +393,7 @@ class QAPISchemaObjectType(QAPISchemaType): def __init__(self, name, info, doc, ifcond, features, base, local_members, variants): # struct has local_members, optional base, and no variants - # flat union has base, variants, and no local_members - # simple union has local_members, variants, and no base + # union has base, variants, and no local_members super().__init__(name, info, doc, ifcond, features) self.meta =3D 'union' if variants else 'struct' assert base is None or isinstance(base, str) @@ -465,15 +464,6 @@ def connect_doc(self, doc=3DNone): for m in self.local_members: m.connect_doc(doc) =20 - @property - def ifcond(self): - assert self._checked - if isinstance(self._ifcond, QAPISchemaType): - # Simple union wrapper type inherits from wrapped type; - # see _make_implicit_object_type() - return self._ifcond.ifcond - return self._ifcond - def is_implicit(self): # See QAPISchema._make_implicit_object_type(), as well as # _def_predefineds() @@ -576,10 +566,9 @@ def visit(self, visitor): =20 class QAPISchemaVariants: def __init__(self, tag_name, info, tag_member, variants): - # Flat unions pass tag_name but not tag_member. - # Simple unions and alternates pass tag_member but not tag_name. - # After check(), tag_member is always set, and tag_name remains - # a reliable witness of being used by a flat union. + # 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) !=3D bool(tag_name) assert (isinstance(tag_name, str) or isinstance(tag_member, QAPISchemaObjectTypeMember)) @@ -595,7 +584,7 @@ def set_defined_in(self, name): v.set_defined_in(name) =20 def check(self, schema, seen): - if not self.tag_member: # flat union + if self._tag_name: # union self.tag_member =3D seen.get(c_name(self._tag_name)) base =3D "'base'" # Pointing to the base type when not implicit would be @@ -625,11 +614,11 @@ def check(self, schema, seen): self.info, "discriminator member '%s' of %s must not be condition= al" % (self._tag_name, base)) - else: # simple union + else: # alternate 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: # flat union + if self._tag_name: # union # branches that are not explicitly covered get an empty type cases =3D {v.name for v in self.variants} for m in self.tag_member.type.members: @@ -707,18 +696,10 @@ def describe(self, info): assert role =3D=3D 'member' role =3D 'parameter' elif defined_in.endswith('-base'): - # Implicit type created for a flat union's dict 'base' + # Implicit type created for a union's dict 'base' role =3D 'base ' + role else: - # Implicit type created for a simple union's branch - assert defined_in.endswith('-wrapper') - # Unreachable and not implemented assert False - elif defined_in.endswith('Kind'): - # See QAPISchema._make_implicit_enum_type() - # Implicit enum created for simple union's branches - assert role =3D=3D 'value' - role =3D 'branch' elif defined_in !=3D info.defn_name: return "%s '%s' of type '%s'" % (role, self.name, defined_in) return "%s '%s'" % (role, self.name) @@ -1004,15 +985,6 @@ def _make_enum_members(self, values, info): QAPISchemaIfCond(v.get('if'))) for v in values] =20 - def _make_implicit_enum_type(self, name, info, ifcond, values): - # See also QAPISchemaObjectTypeMember.describe() - name =3D name + 'Kind' # reserved by check_defn_name_str() - self._def_entity(QAPISchemaEnumType( - name, info, None, ifcond, None, - self._make_enum_members(values, info), - None)) - return name - def _make_array_type(self, element_type, info): name =3D element_type + 'List' # reserved by check_defn_name_st= r() if not self.lookup_type(name): @@ -1026,17 +998,9 @@ 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 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 + # The implicit object type has multiple users. This can + # only be a duplicate definition, which will be flagged + # later. pass else: self._def_entity(QAPISchemaObjectType( @@ -1084,49 +1048,28 @@ def _def_struct_type(self, expr, info, doc): def _make_variant(self, case, typ, ifcond, info): return QAPISchemaVariant(case, info, typ, ifcond) =20 - def _make_simple_variant(self, case, typ, ifcond, info): - if isinstance(typ, list): - assert len(typ) =3D=3D 1 - typ =3D self._make_array_type(typ[0], info) - typ =3D self._make_implicit_object_type( - typ, info, self.lookup_type(typ), - 'wrapper', [self._make_member('data', typ, None, None, info)]) - return QAPISchemaVariant(case, info, typ, ifcond) - def _def_union_type(self, expr, info, doc): name =3D expr['union'] + base =3D expr['base'] + tag_name =3D expr['discriminator'] data =3D expr['data'] - base =3D expr.get('base') 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 if isinstance(base, dict): base =3D self._make_implicit_object_type( name, info, ifcond, 'base', self._make_members(base, info)) - if tag_name: - 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'], - 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] + variants =3D [ + self._make_variant(key, value['type'], + QAPISchemaIfCond(value.get('if')), + info) + for (key, value) in data.items()] + members =3D [] self._def_entity( QAPISchemaObjectType(name, info, doc, ifcond, features, base, members, QAPISchemaVariants( - tag_name, info, tag_member, variants)= )) + tag_name, info, None, variants))) =20 def _def_alternate_type(self, expr, info, doc): name =3D expr['alternate'] diff --git a/tests/qapi-schema/flat-union-array-branch.json b/tests/qapi-sc= hema/flat-union-array-branch.json index 0b98820a8f..6dda7ec379 100644 --- a/tests/qapi-schema/flat-union-array-branch.json +++ b/tests/qapi-schema/flat-union-array-branch.json @@ -1,4 +1,4 @@ -# we require flat union branches to be a struct +# we require union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', diff --git a/tests/qapi-schema/flat-union-empty.json b/tests/qapi-schema/fl= at-union-empty.json index 83e1cc7b96..584ed6098c 100644 --- a/tests/qapi-schema/flat-union-empty.json +++ b/tests/qapi-schema/flat-union-empty.json @@ -1,4 +1,4 @@ -# flat union discriminator cannot be empty +# union discriminator enum cannot be empty { 'enum': 'Empty', 'data': [ ] } { 'struct': 'Base', 'data': { 'type': 'Empty' } } { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } } diff --git a/tests/qapi-schema/flat-union-int-branch.json b/tests/qapi-sche= ma/flat-union-int-branch.json index 9370c349e8..567043d9d2 100644 --- a/tests/qapi-schema/flat-union-int-branch.json +++ b/tests/qapi-schema/flat-union-int-branch.json @@ -1,4 +1,4 @@ -# we require flat union branches to be a struct +# we require union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', diff --git a/tests/qapi-schema/flat-union-no-base.err b/tests/qapi-schema/f= lat-union-no-base.err index 5167565b00..c60482f96b 100644 --- a/tests/qapi-schema/flat-union-no-base.err +++ b/tests/qapi-schema/flat-union-no-base.err @@ -1,2 +1,2 @@ flat-union-no-base.json: In union 'TestUnion': -flat-union-no-base.json:8: 'discriminator' requires 'base' +flat-union-no-base.json:8: union misses key 'base' diff --git a/tests/qapi-schema/flat-union-no-base.json b/tests/qapi-schema/= flat-union-no-base.json index 327877b563..f6fe12da3b 100644 --- a/tests/qapi-schema/flat-union-no-base.json +++ b/tests/qapi-schema/flat-union-no-base.json @@ -1,4 +1,4 @@ -# flat unions require a base +# unions require a base { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } { 'struct': 'TestTypeB', diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 0c19d4820e..b10490ccc6 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -30,7 +30,7 @@ { 'struct': 'Empty1', 'data': { } } { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } } =20 -# Likewise for an empty flat union +# Likewise for an empty union { 'union': 'Union', 'base': { 'type': 'EnumOne' }, 'discriminator': 'type', 'data': { } } diff --git a/tests/qapi-schema/reserved-member-u.json b/tests/qapi-schema/r= eserved-member-u.json index 2bfb8f59b6..d982ab5e0c 100644 --- a/tests/qapi-schema/reserved-member-u.json +++ b/tests/qapi-schema/reserved-member-u.json @@ -2,6 +2,6 @@ # We reject use of 'u' as a member name, to allow it for internal use in # putting union branch members in a separate namespace from QMP members. # This is true even for non-unions, because it is possible to convert a -# struct to flat union while remaining backwards compatible in QMP. +# struct to union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision { 'struct': 'Oops', 'data': { '*u': 'str' } } diff --git a/tests/qapi-schema/union-base-empty.json b/tests/qapi-schema/un= ion-base-empty.json index d1843d33b4..6f8ef000db 100644 --- a/tests/qapi-schema/union-base-empty.json +++ b/tests/qapi-schema/union-base-empty.json @@ -1,4 +1,4 @@ -# Flat union with empty base and therefore without discriminator +# Union with empty base and therefore without discriminator =20 { 'struct': 'Empty', 'data': { } } =20 diff --git a/tests/qapi-schema/union-base-no-discriminator.err b/tests/qapi= -schema/union-base-no-discriminator.err index 9cd5d11b0b..a730b7fd3c 100644 --- a/tests/qapi-schema/union-base-no-discriminator.err +++ b/tests/qapi-schema/union-base-no-discriminator.err @@ -1,2 +1,2 @@ union-base-no-discriminator.json: In union 'TestUnion': -union-base-no-discriminator.json:11: 'base' requires 'discriminator' +union-base-no-discriminator.json:11: union misses key 'discriminator' diff --git a/tests/qapi-schema/union-base-no-discriminator.json b/tests/qap= i-schema/union-base-no-discriminator.json index 1409cf5c9e..2e7cae9b22 100644 --- a/tests/qapi-schema/union-base-no-discriminator.json +++ b/tests/qapi-schema/union-base-no-discriminator.json @@ -1,4 +1,4 @@ -# we reject simple unions with a base (or flat unions without discriminato= r) +# we reject unions without discriminator { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } =20 --=20 2.31.1 From nobody Thu Apr 25 05:20:35 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 1631538811577335.0209718683283; Mon, 13 Sep 2021 06:13:31 -0700 (PDT) Received: from localhost ([::1]:34042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPlm6-00075S-Br for importer@patchew.org; Mon, 13 Sep 2021 09:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFa-0000QF-27 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPlFU-0000jU-TT for qemu-devel@nongnu.org; Mon, 13 Sep 2021 08:39: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-313-hkdUQyAzMBOk3PgQXFEsaQ-1; Mon, 13 Sep 2021 08:39:45 -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 1AAE0835DE1 for ; Mon, 13 Sep 2021 12:39:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEAF35D9DD; Mon, 13 Sep 2021 12:39:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 570761136421; Mon, 13 Sep 2021 14:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631536786; 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=zHgsNGjNah71OnQgLH+Bv40egKqf65QC38I5m9vVxtM=; b=N5jMnkV0EEeAAmIaRRZP9TV0Gg2Sisn1KslZKZOzDhg/3fE2sFHgao72eEGL45fZccJv5V N1IY/9lTmnKBOwzzsapc7pnDftNtACKJOhVhmwEz33qcVxToQL/J4/xGldbGpyuiDf/U36 SCH92jZxrBVqtav1yJl7pn5gigjxRGY= X-MC-Unique: hkdUQyAzMBOk3PgQXFEsaQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 22/22] test-clone-visitor: Correct an accidental rename Date: Mon, 13 Sep 2021 14:39:32 +0200 Message-Id: <20210913123932.3306639-23-armbru@redhat.com> In-Reply-To: <20210913123932.3306639-1-armbru@redhat.com> References: <20210913123932.3306639-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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, 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: jsnow@redhat.com, eblake@redhat.com, marcandre.lureau@redhat.com 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: 1631538812191100001 Content-Type: text/plain; charset="utf-8" Commit b359f4b203 "tests: Rename UserDefNativeListUnion to UserDefListUnion" renamed test_clone_native_list() to test_clone_list_union(). The function has nothing to do with unions. Rename it to test_clone_list(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/unit/test-clone-visitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-clone-visitor.c b/tests/unit/test-clone-visito= r.c index 4048018607..5d48e125b8 100644 --- a/tests/unit/test-clone-visitor.c +++ b/tests/unit/test-clone-visitor.c @@ -63,7 +63,7 @@ static void test_clone_alternate(void) qapi_free_AltEnumBool(s_dst); } =20 -static void test_clone_list_union(void) +static void test_clone_list(void) { uint8List *src =3D NULL, *dst; uint8List *tmp =3D NULL; @@ -203,7 +203,7 @@ int main(int argc, char **argv) =20 g_test_add_func("/visitor/clone/struct", test_clone_struct); g_test_add_func("/visitor/clone/alternate", test_clone_alternate); - g_test_add_func("/visitor/clone/list_union", test_clone_list_union); + g_test_add_func("/visitor/clone/list", test_clone_list); g_test_add_func("/visitor/clone/empty", test_clone_empty); g_test_add_func("/visitor/clone/complex1", test_clone_complex1); g_test_add_func("/visitor/clone/complex2", test_clone_complex2); --=20 2.31.1