All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: berto@igalia.com, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qmp-commands: fix incorrect uses of ":O" specifier
Date: Tue, 21 Apr 2015 10:09:10 -0400	[thread overview]
Message-ID: <20150421100910.51e40685@redhat.com> (raw)
In-Reply-To: <1429097404-28027-1-git-send-email-pbonzini@redhat.com>

On Wed, 15 Apr 2015 13:30:04 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> As far as the QMP parser is concerned, neither the 'O' nor the 'q' format specifiers
> put any constraint on the command.  However, there are two differences:
> 
> 1) from a documentation point of view 'O' says that this command takes
> a dictionary.  The dictionary will be converted to QemuOpts in the
> handler to match the corresponding HMP command.
> 
> 2) 'O' sets QMP_ACCEPT_UNKNOWNS, resulting in the command accepting invalid
> extra arguments.  For example the following is accepted:
> 
>    { "execute": "send-key",
>         "arguments": { "keys": [ { "type": "qcode", "data": "ctrl" },
>                                  { "type": "qcode", "data": "alt" },
>                                  { "type": "qcode", "data": "delete" } ], "foo": "bar" } }
> 
> Neither send-key nor migrate-set-capabilities take a QemuOpts-like
> dictionary; they take an array of dictionaries.  And neither command
> really wants to have extra unknown arguments.  Thus, the right
> specifier to use in this case is 'q'; with this patch the above
> command fails with
> 
>    {"error": {"class": "GenericError", "desc": "Invalid parameter 'foo'"}}
> 
> as intended.
> 
> Reported-by: Alberto Garcia <berto@igalia.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Applied to the qmp branch, thanks.

> ---
>  qmp-commands.hx | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 3a42ad0..09f48ba 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -332,7 +332,7 @@ EQMP
>  
>      {
>          .name       = "send-key",
> -        .args_type  = "keys:O,hold-time:i?",
> +        .args_type  = "keys:q,hold-time:i?",
>          .mhandler.cmd_new = qmp_marshal_input_send_key,
>      },
>  
> @@ -3288,7 +3288,7 @@ EQMP
>  
>      {
>          .name       = "migrate-set-capabilities",
> -        .args_type  = "capabilities:O",
> +        .args_type  = "capabilities:q",
>          .params     = "capability:s,state:b",
>  	.mhandler.cmd_new = qmp_marshal_input_migrate_set_capabilities,
>      },

      parent reply	other threads:[~2015-04-21 14:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 11:30 [Qemu-devel] [PATCH] qmp-commands: fix incorrect uses of ":O" specifier Paolo Bonzini
2015-04-15 12:18 ` Alberto Garcia
2015-04-15 12:21   ` Paolo Bonzini
2015-04-21 14:09 ` Luiz Capitulino [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150421100910.51e40685@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.