Skip to contentSkip to conversation

QAPI magician wanted ...

Qemu-devel Igor Mammedov 3 participants 5 messages Oct 12, 2017

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 7 lines · Igor Mammedov

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.

Quoted 6 lines

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'              
   }
Quoted 7 lines

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

Quoted 8 lines

{ "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

Signature · 3 lines
|: 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 :|
#2 lore raw
Quoted 15 lines · On Thu, 12 Oct 2017 13:28:26 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 7 lines · Igor Mammedov

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.

Quoted 6 lines

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

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

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'

Quoted 13 lines
Quoted 13 lines

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

Quoted 8 lines
Quoted 4 lines

{"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

Quoted 7 lines

Though with my suggestion above you could get it to just

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

Regards,
Daniel

#3 lore raw
Quoted 21 lines · Igor Mammedov
Quoted 18 lines · On Thu, 12 Oct 2017 13:28:26 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 7 lines · Igor Mammedov

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.

Quoted 6 lines

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

Quoted 6 lines
Quoted 4 lines
   {
     '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..

Quoted 9 lines
Quoted 3 lines

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

Quoted 4 lines

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.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 29 lines · On Thu, 12 Oct 2017 08:17:16 -0500 Eric Blake <[email protected]> wrote:
Quoted 21 lines · Igor Mammedov
Quoted 18 lines · On Thu, 12 Oct 2017 13:28:26 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 7 lines · Igor Mammedov

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.

Quoted 6 lines

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

Quoted 6 lines
Quoted 4 lines
   {
     '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'

Quoted 7 lines

{ '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.

Quoted 13 lines
Quoted 9 lines
Quoted 3 lines

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

Quoted 4 lines

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.