#include "qapi-event.h"
#include "qmp-introspect.h"
#include "sysemu/qtest.h"
+#include "sysemu/cpus.h"
#include "qemu/cutils.h"
#include "qapi/qmp/dispatch.h"
static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
Error **errp)
{
- *ret_data = qobject_from_json(qmp_schema_json);
+ *ret_data = qobject_from_json(qmp_schema_json, &error_abort);
}
/*
#ifndef CONFIG_SPICE
qmp_unregister_command(&qmp_commands, "query-spice");
#endif
+#ifndef CONFIG_REPLICATION
+ qmp_unregister_command(&qmp_commands, "xen-set-replication");
+ qmp_unregister_command(&qmp_commands, "query-xen-replication-status");
+ qmp_unregister_command(&qmp_commands, "xen-colo-do-checkpoint");
+#endif
#ifndef TARGET_I386
qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection");
#endif
}
goto fail;
}
- qdict_put(qdict, key, qstring_from_str(buf));
+ qdict_put_str(qdict, key, buf);
}
break;
case 'O':
size = -1;
}
}
- qdict_put(qdict, "count", qint_from_int(count));
- qdict_put(qdict, "format", qint_from_int(format));
- qdict_put(qdict, "size", qint_from_int(size));
+ qdict_put_int(qdict, "count", count);
+ qdict_put_int(qdict, "format", format);
+ qdict_put_int(qdict, "size", size);
}
break;
case 'i':
}
val <<= 20;
}
- qdict_put(qdict, key, qint_from_int(val));
+ qdict_put_int(qdict, key, val);
}
break;
case 'o':
monitor_printf(mon, "invalid size\n");
goto fail;
}
- qdict_put(qdict, key, qint_from_int(val));
+ qdict_put_int(qdict, key, val);
p = end;
}
break;
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
- qdict_put(qdict, key, qbool_from_bool(val));
+ qdict_put_bool(qdict, key, val);
}
break;
case '-':
} else {
/* has option */
p++;
- qdict_put(qdict, key, qbool_from_bool(true));
+ qdict_put_bool(qdict, key, true);
}
}
}
cmd->name);
goto fail;
}
- qdict_put(qdict, key, qstring_from_str(p));
+ qdict_put_str(qdict, key, p);
p += len;
}
break;
return (mon->suspend_cnt == 0) ? 1 : 0;
}
-/*
- * Input object checking rules
- *
- * 1. Input object must be a dict
- * 2. The "execute" key must exist
- * 3. The "execute" key must be a string
- * 4. If the "arguments" key exists, it must be a dict
- * 5. If the "id" key exists, it can be anything (ie. json-value)
- * 6. Any argument not listed above is considered invalid
- */
-static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
-{
- const QDictEntry *ent;
- int has_exec_key = 0;
- QDict *input_dict;
-
- input_dict = qobject_to_qdict(input_obj);
- if (!input_dict) {
- error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
- return NULL;
- }
-
-
- for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){
- const char *arg_name = qdict_entry_key(ent);
- const QObject *arg_obj = qdict_entry_value(ent);
-
- if (!strcmp(arg_name, "execute")) {
- if (qobject_type(arg_obj) != QTYPE_QSTRING) {
- error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
- "execute", "string");
- return NULL;
- }
- has_exec_key = 1;
- } else if (!strcmp(arg_name, "arguments")) {
- if (qobject_type(arg_obj) != QTYPE_QDICT) {
- error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
- "arguments", "object");
- return NULL;
- }
- } else if (!strcmp(arg_name, "id")) {
- /* Any string is acceptable as "id", so nothing to check */
- } else {
- error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
- return NULL;
- }
- }
-
- if (!has_exec_key) {
- error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
- return NULL;
- }
-
- return input_dict;
-}
-
static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
{
QObject *req, *rsp = NULL, *id = NULL;
QDict *qdict = NULL;
- const char *cmd_name;
Monitor *mon = cur_mon;
Error *err = NULL;
goto err_out;
}
- qdict = qmp_check_input_obj(req, &err);
- if (!qdict) {
- goto err_out;
- }
-
- id = qdict_get(qdict, "id");
- qobject_incref(id);
- qdict_del(qdict, "id");
-
- cmd_name = qdict_get_str(qdict, "execute");
- trace_handle_qmp_command(mon, cmd_name);
+ qdict = qobject_to_qdict(req);
+ if (qdict) {
+ id = qdict_get(qdict, "id");
+ qobject_incref(id);
+ qdict_del(qdict, "id");
+ } /* else will fail qmp_dispatch() */
rsp = qmp_dispatch(cur_mon->qmp.commands, req);
QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) {
/* Provide a more useful error message */
qdict_del(qdict, "desc");
- qdict_put(qdict, "desc",
- qstring_from_str("Expecting capabilities negotiation"
- " with 'qmp_capabilities'"));
+ qdict_put_str(qdict, "desc", "Expecting capabilities negotiation"
+ " with 'qmp_capabilities'");
}
}