From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWaJy-0005MK-EP for qemu-devel@nongnu.org; Mon, 31 Aug 2015 21:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWaJt-0007Fj-CE for qemu-devel@nongnu.org; Mon, 31 Aug 2015 21:25:10 -0400 Received: from [59.151.112.132] (port=60553 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWaJs-0007Ab-RE for qemu-devel@nongnu.org; Mon, 31 Aug 2015 21:25:05 -0400 Message-ID: <55E4FE64.4050706@cn.fujitsu.com> Date: Tue, 1 Sep 2015 09:24:52 +0800 From: Yang Hongyang MIME-Version: 1.0 References: <1440583182-5828-1-git-send-email-yanghy@cn.fujitsu.com> <1440583182-5828-4-git-send-email-yanghy@cn.fujitsu.com> <878u8ym649.fsf@blackfin.pond.sub.org> <55DDDD33.3000507@redhat.com> <87k2sfabku.fsf@blackfin.pond.sub.org> <55E3AFA2.1040702@cn.fujitsu.com> <871tek540h.fsf@blackfin.pond.sub.org> <55E417D0.8050800@cn.fujitsu.com> <55E46A6E.4010305@redhat.com> In-Reply-To: <55E46A6E.4010305@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v8 03/11] netfilter: add netfilter_{add|del} commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Markus Armbruster Cc: thuth@redhat.com, zhang.zhanghailiang@huawei.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, qemu-devel@nongnu.org, mrhines@linux.vnet.ibm.com, Luiz Capitulino , stefanha@redhat.com On 08/31/2015 10:53 PM, Eric Blake wrote: > 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. Now I understand, with the flat union, all I need to do now is to specify the command schema like: { 'command': 'netfilter-add', 'data': { 'data': 'NetFilter' } } and use the qmp command like you noted above. Thanks a lot Eric! > >> >> 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. > -- Thanks, Yang.