@@ -76,6 +76,7 @@
#include "qapi-event.h"
#include "qmp-introspect.h"
#include "sysemu/block-backend.h"
+#include "qapi/qmp/dispatch.h"
/* for hmp_info_irq/pic */
#if defined(TARGET_SPARC)
@@ -3536,21 +3537,21 @@ static int monitor_can_read(void *opaque)
return (mon->suspend_cnt == 0) ? 1 : 0;
}
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const gchar *cmd,
Error **errp)
{
- bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+ bool is_cap = !g_strcmp0(cmd, "qmp_capabilities");
if (is_cap && mon->qmp.in_command_mode) {
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
- "'%s' ignored", cmd->name);
+ "'%s' ignored", cmd);
return true;
}
if (!is_cap && !mon->qmp.in_command_mode) {
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"Expecting capabilities negotiation with "
- "'qmp_capabilities' before command '%s'", cmd->name);
+ "'qmp_capabilities' before command '%s'", cmd);
return true;
}
return false;
@@ -3841,7 +3842,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
"The command %s has not been found", cmd_name);
goto err_out;
}
- if (invalid_qmp_mode(mon, cmd, &local_err)) {
+ if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
goto err_out;
}
@@ -3926,9 +3927,13 @@ void monitor_resume(Monitor *mon)
static QObject *get_qmp_greeting(void)
{
+ QmpCommand *cmd;
QObject *ver = NULL;
- qmp_marshal_query_version(NULL, &ver, NULL);
+ cmd = qmp_find_command("query-version");
+ assert(cmd && cmd->fn);
+ cmd->fn(NULL, &ver, NULL);
+
return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
}