[libvirt] [PATCH 01/19] virsh: Add QMP command wrapping for 'qemu-monitor-command'

Michal Privoznik mprivozn at redhat.com
Thu Dec 12 18:30:27 UTC 2019


On 12/12/19 7:16 PM, Eric Blake wrote:
> On 12/12/19 11:18 AM, Peter Krempa wrote:
>> Issuing simple QMP commands is pain as they need to be wrapped by the
>> JSON wrapper:
>>
>>   { "execute": "COMMAND" }
>>
>> and optionally also:
>>
>>   { "execute": "COMMAND", "arguments":...}
>>
>> For simple commands without arguments we can add syntax sugar to virsh
>> which allows simple usage of QMP and additionally prepares also for
>> passing through of the 'arguments' section.
> 
> I'd give an example of the new syntax in the commit message:
> 
> virsh qemu-monitor-command domain --qmp COMMAND '{ARGUMENTS...}'
> 
> as shorthand for
> 
> virsh qemu-monitor-command domain '"execute":"COMMAND", 
> "arguments":{ARGUMENTS...}}'
> 
> But the sugar is indeed nice (one less layer of {} JSON).

Since we won't use HMP to talk to qemu ever (even the small set of HMP 
commands we have are wrapped inside QMP once being sent down the wire), 
can we not use --qmp flag at all? Just look if there's "execute" in the 
user's input and if not add it there. For instance:

   virsh qemu-monitor-command query-machines

will expand to

   {"execute":"query-machines"}

and:

   virsh qemu-monitor-command '{"execute":"query-machines"}'

will do nothing to the user's input.

Michal




More information about the libvir-list mailing list