Received: from eggs.gnu.org ([2001:4830:134:3::10]:35236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlGwJ-0001rC-Ed for qemu-devel@nongnu.org; Thu, 23 Apr 2015 09:13:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlGwE-0007xU-6n for qemu-devel@nongnu.org; Thu, 23 Apr 2015 09:13:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlGwE-0007xO-1c for qemu-devel@nongnu.org; Thu, 23 Apr 2015 09:13:06 -0400 Date: Thu, 23 Apr 2015 15:13:03 +0200 From: Kevin Wolf Message-ID: <20150423131303.GJ5289@noname.redhat.com> References: <1427995743-7865-1-git-send-email-armbru@redhat.com> <1427995743-7865-20-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427995743-7865-20-git-send-email-armbru@redhat.com> Subject: Re: [Qemu-devel] [PATCH RFC 19/19] qapi: New QMP command query-schema for QMP schema introspection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: berto@igalia.com, akong@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com One question in addition to what Eric already asked: Am 02.04.2015 um 19:29 hat Markus Armbruster geschrieben: > +{ 'enum': 'SchemaMetaType', > + 'data': [ 'builtin', 'enum', 'array', 'object', 'alternate', > + 'command', 'event' ] } > + > +{ 'type': 'SchemaInfoBase', > + 'data': { 'name': 'str', 'meta-type': 'SchemaMetaType' } } > + > +{ 'enum': 'JSONPrimitiveType', > + 'data': [ 'str', 'int', 'number', 'bool', 'null' ] } > + > +{ 'type': 'SchemaInfoBuiltin', > + 'data': { 'json-type': 'JSONPrimitiveType' } } > + > +{ 'type': 'SchemaInfoEnum', > + 'data': { 'values': ['str'] } } > + > +{ 'type': 'SchemaInfoArray', > + 'data': { 'element-type': 'str' } } > + > +{ 'alternate': 'Value', > + 'data': { 'int': 'int', 'number': 'number', 'str': 'str', 'bool': 'bool' } } > + > +{ 'type': 'SchemaInfoObjectMember', > + 'data': { 'name': 'str', 'type': 'str', '*default': 'Value' } } > +# @default's type must match @type > +# can only default simple types, not objects or arrays > + > +{ 'type': 'SchemaInfoObjectVariant', > + 'data': { 'case': 'str', > + 'members': [ 'SchemaInfoObjectMember' ] } } > + > +{ 'type': 'SchemaInfoObject', > + 'data': { 'members': [ 'SchemaInfoObjectMember' ], > + '*discriminator': 'str', > + '*variants': [ 'SchemaInfoObjectVariant' ] } } > + > +{ 'type': 'SchemaInfoAlternate', > + 'data': { 'members': [ 'SchemaInfoObjectMember' ] } } I'm not sure if I understand correctly how this one works. My guess would be this: - The elements in members describe the different variants. That is, you choose of the members, whereas in SchemaInfoObject all of the members exist. Perhaps they should be using different names then? - The type (= discriminator) of a variant is indirectly specified by the 'type' of the SchemaInfoObjectMember: This is a QAPI type, but the JSON type can be resolved by checking 'meta-type' of the QAPI type (and SchemaInfoBuiltin if necessary) - The 'name' in SchemaInfoObjectMember could be the key name of the variant in the alternate definition. However, this name isn't used anywhere in the QMP protocol, so maybe it is better kept internal. 'name' isn't optional, though. - The 'default' of SchemaInfoObjectMember must be omitted. Do I understand the intention reasonably right? If so, maybe it would be better to use a separate type for alternate variants. Kevin