From nobody Tue Feb 10 12:42:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515707360418287.1198477366513; Thu, 11 Jan 2018 13:49:20 -0800 (PST) Received: from localhost ([::1]:44992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZkis-0001WM-FG for importer@patchew.org; Thu, 11 Jan 2018 16:49:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZkWM-0007Tl-PF for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZkWM-0004Ow-17 for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54814) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZkWL-0004Nv-RX for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:21 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 031F283F3E; Thu, 11 Jan 2018 21:36:21 +0000 (UTC) Received: from localhost (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4460C67DC3; Thu, 11 Jan 2018 21:36:17 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 22:32:31 +0100 Message-Id: <20180111213250.16511-33-marcandre.lureau@redhat.com> In-Reply-To: <20180111213250.16511-1-marcandre.lureau@redhat.com> References: <20180111213250.16511-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 Jan 2018 21:36:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 32/51] docs: document schema configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com, Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/devel/qapi-code-gen.txt | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index f58d62686a..479b755609 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -682,6 +682,44 @@ Example: Red Hat, Inc. controls redhat.com, and may th= erefore add a downstream command __com.redhat_drive-mirror. =20 =20 +=3D=3D=3D Configuring the schema =3D=3D=3D + +Top-level QAPI expressions and various type expressions listed below +can take an 'if' key. The value must be a string or a list of +string. The corresponding generated code will then guard the inclusion +of that member in the larger struct or function with #if IFCOND +(or several #if lines for a list), where IFCOND is the value of the +'if' key. + +'struct', 'enum', 'union', 'alternate', 'command' and 'event' +top-level QAPI expressions can take an 'if' keyword like: + +{ 'struct': 'IfStruct', 'data': { 'foo': 'int' }, + 'if': 'defined(IFCOND)' } + +Where a member can normally be defined with a single string value as its +type, it is also possible to supply a dictionary with both 'type' and +'if' keys. + +{ 'struct': 'IfStruct', 'data': + { 'foo': 'int', + 'bar': { 'type': 'int', 'if': 'defined(IFCOND)'} } } + +An enum value can be replaced by a dictionary with a 'name' and a 'if' +key: + +{ 'enum': 'IfEnum', 'data': + [ 'foo', + { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] } + +Please note that you are responsible to ensure that the C code will +compile with an arbitrary combination of conditions, since the +generators are unable to check it at this point. + +The presence of 'if' keys in the schema is reflected through to the +introspection output depending on the build configuration. + + =3D=3D Client JSON Protocol introspection =3D=3D =20 Clients of a Client JSON Protocol commonly need to figure out what --=20 2.16.0.rc1.1.gef27df75a1