[libvirt] [PATCH] qemu: Use QMP for send-key if supported

Eric Blake eblake at redhat.com
Thu Apr 11 13:00:24 UTC 2013


On 04/11/2013 06:45 AM, Peter Krempa wrote:
> Instead of always using HMP use the QMP send-key command introduced in qemu 1.3.
> ---

> +++ b/src/qemu/qemu_monitor.c
> @@ -3008,14 +3008,15 @@ int qemuMonitorInjectNMI(qemuMonitorPtr mon)
>  int qemuMonitorSendKey(qemuMonitorPtr mon,
>                         unsigned int holdtime,
>                         unsigned int *keycodes,
> -                       unsigned int nkeycodes)
> +                       unsigned int nkeycodes,
> +                       bool useQMP)
>  {
>      int ret;
> 
>      VIR_DEBUG("mon=%p, holdtime=%u, nkeycodes=%u",
>                mon, holdtime, nkeycodes);
> 
> -    if (mon->json)
> +    if (mon->json && useQMP)
>          ret = qemuMonitorJSONSendKey(mon, holdtime, keycodes, nkeycodes);
>      else
>          ret = qemuMonitorTextSendKey(mon, holdtime, keycodes, nkeycodes);

I'm not sure I like adding the useQMP parameter.  That makes for a leaky
abstraction (the caller is burdened with telling us which version of a
polymorphic function to dispatch to).  What we have done in other cases
is to always dispatch to the json code, and then have the json code
_try_ the command, and if the command fails, fall back to the hmp
command.  See for example qemuMonitorJSONInjectNMI.  And if you do it
that way, you don't even need a qemu_capabilities bit, and the caller no
longer has to care about which version of monitor it is talking to.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130411/e8414daa/attachment-0001.sig>


More information about the libvir-list mailing list