Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-20 Thread Anthony Liguori
On 03/20/2012 07:15 AM, Luiz Capitulino wrote: So let's work through a few examples. Today, you have to maintain a list of commands returned from query-commands and check for set membership: if 'query-netdev2' in commands: qmp.query_netdev2(foo) else: qmp.query_netdev() Pretty simpl

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-20 Thread Paolo Bonzini
Il 19/03/2012 20:56, Anthony Liguori ha scritto: > I'm not sure if the "server ignores unknown" fields thing is even > reasonable to rely upon so maybe we should just draw a line in the sane > and make the change you're suggesting... Yeah, especially since right now it's half-half (worst of both w

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-20 Thread Luiz Capitulino
On Mon, 19 Mar 2012 19:49:46 -0500 Anthony Liguori wrote: > On 03/19/2012 06:45 PM, Michael Roth wrote: > >>> So IMO, returning arguments actually seems easier for both clients and the > >>> server, and is more resilient to downstream changes. It does require a > >>> more > >>> formal specificat

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Anthony Liguori
On 03/19/2012 06:45 PM, Michael Roth wrote: So IMO, returning arguments actually seems easier for both clients and the server, and is more resilient to downstream changes. It does require a more formal specification of the protocol though. Basically: "an option/field may not be supported in older

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Michael Roth
On Mon, Mar 19, 2012 at 08:29:28PM +0100, Paolo Bonzini wrote: > I noticed that the QMP input visitor does not detect extra members inside > structs. The outermost arguments struct is handled by the QMP type > checker, but the nested ones go undetected. That could be a problem > for complex comma

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Michael Roth
On Mon, Mar 19, 2012 at 05:38:54PM -0500, Anthony Liguori wrote: > On 03/19/2012 05:29 PM, Michael Roth wrote: > >On Mon, Mar 19, 2012 at 05:43:14PM -0300, Luiz Capitulino wrote: > >>On Mon, 19 Mar 2012 15:30:26 -0500 > >>Anthony Liguori wrote: > >> > >>>On 03/19/2012 03:22 PM, Eric Blake wrote: >

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Anthony Liguori
On 03/19/2012 05:29 PM, Michael Roth wrote: On Mon, Mar 19, 2012 at 05:43:14PM -0300, Luiz Capitulino wrote: On Mon, 19 Mar 2012 15:30:26 -0500 Anthony Liguori wrote: On 03/19/2012 03:22 PM, Eric Blake wrote: On 03/19/2012 01:56 PM, Anthony Liguori wrote: For old clients that could be fine.

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Michael Roth
On Mon, Mar 19, 2012 at 05:43:14PM -0300, Luiz Capitulino wrote: > On Mon, 19 Mar 2012 15:30:26 -0500 > Anthony Liguori wrote: > > > On 03/19/2012 03:22 PM, Eric Blake wrote: > > > On 03/19/2012 01:56 PM, Anthony Liguori wrote: > > >>> For old clients that could be fine. But what about old serve

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Luiz Capitulino
On Mon, 19 Mar 2012 15:30:26 -0500 Anthony Liguori wrote: > On 03/19/2012 03:22 PM, Eric Blake wrote: > > On 03/19/2012 01:56 PM, Anthony Liguori wrote: > >>> For old clients that could be fine. But what about old servers? :) > >> > >> Same applies to old server. If a new client tries to use a

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Anthony Liguori
On 03/19/2012 03:22 PM, Eric Blake wrote: On 03/19/2012 01:56 PM, Anthony Liguori wrote: For old clients that could be fine. But what about old servers? :) Same applies to old server. If a new client tries to use a new field, if the old server refuses it, then the new client breaks. I rece

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Eric Blake
On 03/19/2012 01:56 PM, Anthony Liguori wrote: >> For old clients that could be fine. But what about old servers? :) > > Same applies to old server. If a new client tries to use a new field, > if the old server refuses it, then the new client breaks. I recently asked this question, and I was to

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Anthony Liguori
On 03/19/2012 02:51 PM, Paolo Bonzini wrote: Il 19/03/2012 20:34, Anthony Liguori ha scritto: Is this acceptable or just wrong? This is a feature. The idea is that with QMP, old clients just ignore extra members in a structure. I've never felt that comfortable with this as a semantic b

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Paolo Bonzini
Il 19/03/2012 20:34, Anthony Liguori ha scritto: >> >> Is this acceptable or just wrong? > > This is a feature. The idea is that with QMP, old clients just ignore > extra members in a structure. I've never felt that comfortable with > this as a semantic but this is how QMP was designed. For

Re: [Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Anthony Liguori
On 03/19/2012 02:29 PM, Paolo Bonzini wrote: I noticed that the QMP input visitor does not detect extra members inside structs. The outermost arguments struct is handled by the QMP type checker, but the nested ones go undetected. That could be a problem for complex commands such as "transaction

[Qemu-devel] [RFC/RFA PATCH] qapi: detect extra members inside structs

2012-03-19 Thread Paolo Bonzini
I noticed that the QMP input visitor does not detect extra members inside structs. The outermost arguments struct is handled by the QMP type checker, but the nested ones go undetected. That could be a problem for complex commands such as "transaction". This patch adds such detection to the QMP i