Received: from eggs.gnu.org ([2001:4830:134:3::10]:41297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAF-0001UW-5E for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:02:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdKAB-0006i4-UK for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:02:43 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:11394 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAB-0006hf-Nl for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:02:39 -0400 Date: Wed, 1 Apr 2015 17:02:36 +0200 From: Alberto Garcia Message-ID: <20150401150236.GA28058@igalia.com> References: <54F9DFCB.8000204@redhat.com> <20150311091809.GA13472@igalia.com> <874mprq1fs.fsf@blackfin.pond.sub.org> <20150311160228.GA27897@igalia.com> <8761a7uynw.fsf@blackfin.pond.sub.org> <20150312123959.GA7029@noname.redhat.com> <87bnjvy2vi.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bnjvy2vi.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH 0/1] Get the list of arguments from a QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Michael Roth , Amos Kong , qemu-devel@nongnu.org, Luiz Capitulino On Sat, Mar 14, 2015 at 05:12:33PM +0100, Markus Armbruster wrote: [QMP introspection] > Detail. I want us to figure out what information we want to provide > first, how to encode it second, and how to fit it into the existing > introspection interfaces third. Ok, I managed to find some time to take look at this. Here's a rough proposal of the kind of information we can provide and how to encode it. The type names I'm using are probably not very well thought-out, but my intention at this point is to discuss the structure rather than the names. So let's start with the basics: { 'type': 'SimpleTypeInfo', 'data': { 'name': 'str', 'array': 'bool' } } This would be what describes a single, named data type (as opposed to a dictionary). The name would refer to any of the build-in types, complex types, enums or unions. Alternatively instead of an 'str' it could also be an enum, which could be auto-generated and would contain all possible type names. I don't know if this last option is feasible, I had the impression that it's not for commands with 'gen' == 'no', but correct me if I'm wrong. Then I think that all instances where a simple type can appear also allow arrays, so an additional boolean field can be used for that, e.g.: 'returns': 'str' // name: str, array: no 'returns': ['EventInfo'] // name: EventInfo, array: yes Next: { 'type': 'DataFieldInfo', 'data': { 'name': 'str', 'optional': 'bool', 'type': 'SimpleTypeInfo' } } That's for command arguments and fields in complex data types and events. I think this one does not need much explanation. I admit that the name that I chose is not very good :) { 'type': 'ComplexTypeInfo', 'data': { 'name': 'str', 'fields': [ 'DataFieldInfo' ] } } { 'type': 'EnumInfo', 'data': { 'name': 'str', 'values': [ 'str' ] } } { 'type': 'EventInfo', 'data': { 'name': 'str', 'fields': [ 'DataFieldInfo' ] } } This is for complex types, unions and events. I also think they don't need much explanation. ComplexTypeInfo and EventInfo could be merged into the same type, although I guess it's a good idea to keep them separated in case one of them needs to be extended in the future. { 'type': 'UnionFieldInfo', 'data': { 'name': 'str', 'type': 'str', } } { 'type': 'UnionInfo', 'data': { 'name': 'str', '*base': 'str' '*discriminator': 'str', 'fields': [ 'UnionFieldInfo' ] } } Unions. The type for 'base' could be (instead of 'str') an autogenerated enum with all complex data types. 'discriminator' would be 'type' for the default case. If the union is anonymous then this field would be absent. { 'type': 'CommandInfo', 'data': { 'name': 'str', 'args': [ 'DataFieldInfo' ], '*returns': 'SimpleTypeInfo', 'gen': 'bool', 'success-response': 'bool' } } Commands. As far as I can see all of them return a single type (or an array thereof), but this could be replaced if we want something else. I think that's all. Then as you said we could hide complex types and flatten them all when we expose them. It would probably makes things easier in terms of allowing changes in the API, but sounds like it would make the life of API users more difficult? I don't know. Last, about the query commands, I don't think they're so important at the moment. Whether we want to have 'query-schema' or a set of 'query-*' for different things, or a combination of both, is something that does not really have much impact on this discussion. Once we know what we want to expose, the commands will come naturally I think. Berto