On 08/31/2015 03:01 AM, Yang Hongyang wrote: > > Sorry that I don't know much about the QAPI part, I have a question, in > previous reply, Eric suggested: > > > > Then this becomes something like: > > > > { 'command': 'netfilter-add', 'data': 'NetFilter' } >
If we do this (which requires pending patches to be flushed), then the user specifies the following QMP: { "execute":"netfilter-add", "arguments":{ "id":"abc", "netdev":"def", "type":"dummy" }} > or use NetFilter as a union, but have the command be: > > { 'command': 'netfilter-add', > 'data': { 'data': 'NetFilter' } } This approach would work right now without waiting for pending qapi commits, but the QMP command would look like: { "execute":"netfilter-add", "arguments":{ "data":{ "id":"abc", "netdev":"def", "type":"dummy" }}} > > where you have to pass an extra layer of nesting at the QMP layer. > > What do you mean by pass an extra layer of nesting? The fact that I had to pass "arguments":{"data":{...}}, thereby nesting the real options inside another relatively pointless data wrapper. > > I've already switched to flat union as you suggested: > > { 'struct': 'NetFilterDummyOptions', > 'data': { } } > > { 'enum': 'NetFilterType', > 'data': ['dummy'] } > > { 'struct': 'NetFilterBase', > 'data': { > 'id': 'str', > 'netdev': 'str', > '*chain': 'str', > 'type': 'NetFilterType' } } > > { 'union': 'NetFilter', > 'base': 'NetFilterBase', > 'discriminator': 'type', > 'data': { > 'dummy': 'NetFilterDummyOptions' } } Looks reasonable for a first round. Some of the pending qapi commits may allow us to further simplify things to not be quite so verbose, but that doesn't stop us from using this now. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature