qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] QAPI magician wanted ...
@ 2017-10-12 12:21 Igor Mammedov
  2017-10-12 12:28 ` Daniel P. Berrange
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Mammedov @ 2017-10-12 12:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Markus Armbruster, Eric Blake


I'm working on introducing QMP command to set numa mappings
via QMP interface at runtime instead of CLI.

I'd prefer to reuse NumaOptions for parsing input,
but I can't wrap my head around QAPI magic.

So far I've added new command in qapi-schema.json:

  {
    'command': 'set-numa-node',                                                    
    'data': {'cmd': 'NumaOptions'}                                                 
  }

it at least compiles and manages to handle input without union part

  { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node" } } }

however I can't figure out syntax that adds union part to it,
I have tried something like this

  { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "node" : { "nodeid": 1 } } } }

but it errors out with

  {"error": {"class": "GenericError", "desc": "Parameter 'cmd.node' is unexpected"}}

Any advice on how to make it work if possible at all or
alternative ways how to achieve the end goal.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] QAPI magician wanted ...
  2017-10-12 12:21 [Qemu-devel] QAPI magician wanted Igor Mammedov
@ 2017-10-12 12:28 ` Daniel P. Berrange
  2017-10-12 12:38   ` Igor Mammedov
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel P. Berrange @ 2017-10-12 12:28 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Markus Armbruster

On Thu, Oct 12, 2017 at 02:21:53PM +0200, Igor Mammedov wrote:
> 
> I'm working on introducing QMP command to set numa mappings
> via QMP interface at runtime instead of CLI.
> 
> I'd prefer to reuse NumaOptions for parsing input,
> but I can't wrap my head around QAPI magic.
> 
> So far I've added new command in qapi-schema.json:
> 
>   {
>     'command': 'set-numa-node',                                                    
>     'data': {'cmd': 'NumaOptions'}                                                 
>   }

I don't see any point in the extra level of nesting you have here, vs
using NumaOptions as the data directly eg

   {
     'command': 'set-numa-node',
     'data': 'NumaOptions'              
   }


> it at least compiles and manages to handle input without union part
> 
>   { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node" } } }
> 
> however I can't figure out syntax that adds union part to it,
> I have tried something like this
> 
>   { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "node" : { "nodeid": 1 } } } }
> 
> but it errors out with
> 
>   {"error": {"class": "GenericError", "desc": "Parameter 'cmd.node' is unexpected"}}
> 
> Any advice on how to make it work if possible at all or
> alternative ways how to achieve the end goal.

I think the union gets flattenned - ie you probably want

   { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "nodeid": 1 } } }

Though with my suggestion above you could get it to just

   { "execute": "set-numa-node", "arguments": { "type": "node", "nodeid": 1 } }

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] QAPI magician wanted ...
  2017-10-12 12:28 ` Daniel P. Berrange
@ 2017-10-12 12:38   ` Igor Mammedov
  2017-10-12 13:17     ` Eric Blake
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Mammedov @ 2017-10-12 12:38 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, Markus Armbruster

On Thu, 12 Oct 2017 13:28:26 +0100
"Daniel P. Berrange" <berrange@redhat.com> wrote:

> On Thu, Oct 12, 2017 at 02:21:53PM +0200, Igor Mammedov wrote:
> > 
> > I'm working on introducing QMP command to set numa mappings
> > via QMP interface at runtime instead of CLI.
> > 
> > I'd prefer to reuse NumaOptions for parsing input,
> > but I can't wrap my head around QAPI magic.
> > 
> > So far I've added new command in qapi-schema.json:
> > 
> >   {
> >     'command': 'set-numa-node',                                                    
> >     'data': {'cmd': 'NumaOptions'}                                                 
> >   }  
> 
> I don't see any point in the extra level of nesting you have here, vs
> using NumaOptions as the data directly eg
> 
>    {
>      'command': 'set-numa-node',
>      'data': 'NumaOptions'              
>    }
I've tried that, it doesn't compile
   'data' for command 'set-numa-node' cannot use union type 'NumaOptions'

> 
> 
> > it at least compiles and manages to handle input without union part
> > 
> >   { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node" } } }
> > 
> > however I can't figure out syntax that adds union part to it,
> > I have tried something like this
> > 
> >   { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "node" : { "nodeid": 1 } } } }
> > 
> > but it errors out with
> > 
> >   {"error": {"class": "GenericError", "desc": "Parameter 'cmd.node' is unexpected"}}
> > 
> > Any advice on how to make it work if possible at all or
> > alternative ways how to achieve the end goal.  
> 
> I think the union gets flattenned - ie you probably want
> 
>    { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "nodeid": 1 } } }
thanks, that works for me 

> 
> Though with my suggestion above you could get it to just
> 
>    { "execute": "set-numa-node", "arguments": { "type": "node", "nodeid": 1 } }
> 
> Regards,
> Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] QAPI magician wanted ...
  2017-10-12 12:38   ` Igor Mammedov
@ 2017-10-12 13:17     ` Eric Blake
  2017-10-12 16:29       ` Igor Mammedov
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2017-10-12 13:17 UTC (permalink / raw)
  To: Igor Mammedov, Daniel P. Berrange; +Cc: qemu-devel, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]

On 10/12/2017 07:38 AM, Igor Mammedov wrote:
> On Thu, 12 Oct 2017 13:28:26 +0100
> "Daniel P. Berrange" <berrange@redhat.com> wrote:
> 
>> On Thu, Oct 12, 2017 at 02:21:53PM +0200, Igor Mammedov wrote:
>>>
>>> I'm working on introducing QMP command to set numa mappings
>>> via QMP interface at runtime instead of CLI.
>>>
>>> I'd prefer to reuse NumaOptions for parsing input,
>>> but I can't wrap my head around QAPI magic.
>>>
>>> So far I've added new command in qapi-schema.json:
>>>
>>>   {
>>>     'command': 'set-numa-node',                                                    
>>>     'data': {'cmd': 'NumaOptions'}                                                 
>>>   }  
>>
>> I don't see any point in the extra level of nesting you have here, vs
>> using NumaOptions as the data directly eg
>>
>>    {
>>      'command': 'set-numa-node',
>>      'data': 'NumaOptions'              
>>    }
> I've tried that, it doesn't compile
>    'data' for command 'set-numa-node' cannot use union type 'NumaOptions'

{ 'command': 'set-numa-node', 'boxed': true,
  'data': 'NumaOptions' }

To use a union directly as the command (which is a GOOD idea), you have
to tell the generator to pass it as a boxed item to the
qmp_set_numa_node function, rather than as exploded parameters, since
the generator can't explode parameters from a union..

>> I think the union gets flattenned - ie you probably want
>>
>>    { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "nodeid": 1 } } }
> thanks, that works for me 
> 
>>
>> Though with my suggestion above you could get it to just
>>
>>    { "execute": "set-numa-node", "arguments": { "type": "node", "nodeid": 1 } }

Yes, I'd prefer this form without the extra nesting.


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] QAPI magician wanted ...
  2017-10-12 13:17     ` Eric Blake
@ 2017-10-12 16:29       ` Igor Mammedov
  0 siblings, 0 replies; 5+ messages in thread
From: Igor Mammedov @ 2017-10-12 16:29 UTC (permalink / raw)
  To: Eric Blake; +Cc: Daniel P. Berrange, qemu-devel, Markus Armbruster

On Thu, 12 Oct 2017 08:17:16 -0500
Eric Blake <eblake@redhat.com> wrote:

> On 10/12/2017 07:38 AM, Igor Mammedov wrote:
> > On Thu, 12 Oct 2017 13:28:26 +0100
> > "Daniel P. Berrange" <berrange@redhat.com> wrote:
> >   
> >> On Thu, Oct 12, 2017 at 02:21:53PM +0200, Igor Mammedov wrote:  
> >>>
> >>> I'm working on introducing QMP command to set numa mappings
> >>> via QMP interface at runtime instead of CLI.
> >>>
> >>> I'd prefer to reuse NumaOptions for parsing input,
> >>> but I can't wrap my head around QAPI magic.
> >>>
> >>> So far I've added new command in qapi-schema.json:
> >>>
> >>>   {
> >>>     'command': 'set-numa-node',                                                    
> >>>     'data': {'cmd': 'NumaOptions'}                                                 
> >>>   }    
> >>
> >> I don't see any point in the extra level of nesting you have here, vs
> >> using NumaOptions as the data directly eg
> >>
> >>    {
> >>      'command': 'set-numa-node',
> >>      'data': 'NumaOptions'              
> >>    }  
> > I've tried that, it doesn't compile
> >    'data' for command 'set-numa-node' cannot use union type 'NumaOptions'  
> 
> { 'command': 'set-numa-node', 'boxed': true,
>   'data': 'NumaOptions' }
> 
> To use a union directly as the command (which is a GOOD idea), you have
> to tell the generator to pass it as a boxed item to the
> qmp_set_numa_node function, rather than as exploded parameters, since
> the generator can't explode parameters from a union..
Thanks for suggestion,
it works and I don't need extra nesting anymore.


> >> I think the union gets flattenned - ie you probably want
> >>
> >>    { "execute": "set-numa-node", "arguments": { "cmd": { "type": "node", "nodeid": 1 } } }  
> > thanks, that works for me 
> >   
> >>
> >> Though with my suggestion above you could get it to just
> >>
> >>    { "execute": "set-numa-node", "arguments": { "type": "node", "nodeid": 1 } }  
> 
> Yes, I'd prefer this form without the extra nesting.
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-12 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12 12:21 [Qemu-devel] QAPI magician wanted Igor Mammedov
2017-10-12 12:28 ` Daniel P. Berrange
2017-10-12 12:38   ` Igor Mammedov
2017-10-12 13:17     ` Eric Blake
2017-10-12 16:29       ` Igor Mammedov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).