Commit 43d0a2c1 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Luiz Capitulino
Browse files

qmp-commands: fix incorrect uses of ":O" specifier



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: default avatarAlberto Garcia <berto@igalia.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
parent 6540e9f3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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,
    },