Message ID | 1443189844-20341-5-git-send-email-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 09/25/2015 08:03 AM, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > This was initially done to add qmp_capabilities documentation to the > schema. Then I figured it would also help to get rid of the "middle > mode" monitor dispatch code. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > monitor.c | 4 ++-- > qapi-schema.json | 17 +++++++++++++++++ > qmp-commands.hx | 2 +- > 3 files changed, 20 insertions(+), 3 deletions(-) > > +++ b/qapi-schema.json > @@ -21,6 +21,23 @@ > { 'include': 'qapi/introspect.json' } > > ## > +# @qmp_capabilities: > +# > +# Enable QMP capabilities. > +# > +# Arguments: None. > +# > +# Example: > +# > +# -> { "execute": "qmp_capabilities" } > +# <- { "return": {} } > +# > +# Notes: This command must be issued before issuing any other command. I'd also mention that it is only accepted once; maybe this is better? Notes: This command is valid exactly when first connecting: it must be issued before any other command will be accepted, and will fail once the monitor is accepting other commands. Otherwise, I'm a fan of this patch.
diff --git a/monitor.c b/monitor.c index 4ae654c..7e8ad0c 100644 --- a/monitor.c +++ b/monitor.c @@ -568,7 +568,7 @@ static void monitor_qapi_event_init(void) qmp_event_set_func_emit(monitor_qapi_event_queue); } -static void qmp_capabilities(QDict *params, QObject **ret_data, Error **errp) +void qmp_qmp_capabilities(Error **errp) { cur_mon->qmp.in_command_mode = true; } @@ -3539,7 +3539,7 @@ static int monitor_can_read(void *opaque) static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd, Error **errp) { - bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities; + bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities; if (is_cap && mon->qmp.in_command_mode) { error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, diff --git a/qapi-schema.json b/qapi-schema.json index eb7beeb..a9b16d9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -21,6 +21,23 @@ { 'include': 'qapi/introspect.json' } ## +# @qmp_capabilities: +# +# Enable QMP capabilities. +# +# Arguments: None. +# +# Example: +# +# -> { "execute": "qmp_capabilities" } +# <- { "return": {} } +# +# Notes: This command must be issued before issuing any other command. +# +## +{ 'command': 'qmp_capabilities' } + +## # @LostTickPolicy: # # Policy for handling lost ticks in timer devices. diff --git a/qmp-commands.hx b/qmp-commands.hx index ebf2880..910edf5 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2018,7 +2018,7 @@ EQMP .args_type = "", .params = "", .help = "enable QMP capabilities", - .mhandler.cmd_new = qmp_capabilities, + .mhandler.cmd_new = qmp_marshal_qmp_capabilities, }, SQMP