From patchwork Tue Feb 28 21:27:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 733886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vXsQc68Y5z9sN4 for ; Wed, 1 Mar 2017 08:38:48 +1100 (AEDT) Received: from localhost ([::1]:37104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cipTp-0008Sc-DC for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2017 16:38:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cipIu-0007b6-IB for qemu-devel@nongnu.org; Tue, 28 Feb 2017 16:27:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cipIs-0000zV-Ds for qemu-devel@nongnu.org; Tue, 28 Feb 2017 16:27:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cipIk-0000s6-WB; Tue, 28 Feb 2017 16:27:19 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B633C002421; Tue, 28 Feb 2017 21:27:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1SLRGcD014779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 28 Feb 2017 16:27:18 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7E9DE11384AC; Tue, 28 Feb 2017 22:27:10 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2017 22:27:09 +0100 Message-Id: <1488317230-26248-24-git-send-email-armbru@redhat.com> In-Reply-To: <1488317230-26248-1-git-send-email-armbru@redhat.com> References: <1488317230-26248-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 28 Feb 2017 21:27:19 +0000 (UTC) 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 v2 23/24] docs/qapi-code-gen.txt: Clarify naming rules 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: kwolf@redhat.com, pkrempa@redhat.com, mdroth@linux.vnet.ibm.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf --- docs/qapi-code-gen.txt | 61 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index 6746c10..9514d93 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -216,33 +216,38 @@ single-dimension array of that type; multi-dimension arrays are not directly supported (although an array of a complex struct that contains an array member is possible). +All names must begin with a letter, and contain only ASCII letters, +digits, hyphen, and underscore. There are two exceptions: enum values +may start with a digit, and names that are downstream extensions (see +section Downstream extensions) start with underscore. + +Names beginning with 'q_' are reserved for the generator, which uses +them for munging QMP names that resemble C keywords or other +problematic strings. For example, a member named "default" in qapi +becomes "q_default" in the generated C code. + Types, commands, and events share a common namespace. Therefore, generally speaking, type definitions should always use CamelCase for -user-defined type names, while built-in types are lowercase. Type -definitions should not end in 'Kind', as this namespace is used for -creating implicit C enums for visiting union types, or in 'List', as -this namespace is used for creating array types. Command names, -and member names within a type, should be all lower case with words -separated by a hyphen. However, some existing older commands and -complex types use underscore; when extending such expressions, -consistency is preferred over blindly avoiding underscore. Event -names should be ALL_CAPS with words separated by underscore. Member -names cannot start with 'has-' or 'has_', as this is reserved for -tracking optional members. +user-defined type names, while built-in types are lowercase. + +Type names ending with 'Kind' or 'List' are reserved for the +generator, which uses them for implicit union enums and array types, +respectively. + +Command names, and member names within a type, should be all lower +case with words separated by a hyphen. However, some existing older +commands and complex types use underscore; when extending such +expressions, consistency is preferred over blindly avoiding +underscore. + +Event names should be ALL_CAPS with words separated by underscore. + +Member names starting with 'has-' or 'has_' are reserved for the +generator, which uses them for tracking optional members. Any name (command, event, type, member, or enum value) beginning with "x-" is marked experimental, and may be withdrawn or changed -incompatibly in a future release. All names must begin with a letter, -and contain only ASCII letters, digits, dash, and underscore. There -are two exceptions: enum values may start with a digit, and any -extensions added by downstream vendors should start with a prefix -matching "__RFQDN_" (for the reverse-fully-qualified-domain-name of -the vendor), even if the rest of the name uses dash (example: -__com.redhat_drive-mirror). Names beginning with 'q_' are reserved -for the generator: QMP names that resemble C keywords or other -problematic strings will be munged in C to use this prefix. For -example, a member named "default" in qapi becomes "q_default" in the -generated C code. +incompatibly in a future release. In the rest of this document, usage lines are given for each expression type, with literal strings written in lower case and @@ -643,6 +648,18 @@ any non-empty complex type (struct, union, or alternate), and a pointer to that QAPI type is passed as a single argument. +=== Downstream extensions === + +QAPI schema names that are externally visible, say in the Client JSON +Protocol, need to be managed with care. Names starting with a +downstream prefix of the form __RFQDN_ are reserved for the downstream +who controls the valid, reverse fully qualified domain name RFQDN. +RFQDN may only contain ASCII letters, digits, hyphen and period. + +Example: Red Hat, Inc. controls redhat.com, and may therefore add a +downstream command __com.redhat_drive-mirror. + + == Client JSON Protocol introspection == Clients of a Client JSON Protocol commonly need to figure out what