QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request, bool allow_oob) { Error *err = NULL; QDict *dict = qobject_to(QDict, request); QObject *ret, *id = dict ? qdict_get(dict, "id") : NULL; QDict *rsp; ret = do_qmp_dispatch(cmds, request, allow_oob, &err); if (err) { rsp = qmp_error_response(err); } else if (ret) { rsp = qdict_new(); qdict_put_obj(rsp, "return", ret); } else { /* Can only happen for commands with QCO_NO_SUCCESS_RESP */ rsp = NULL; } if (rsp && id) { qdict_put_obj(rsp, "id", qobject_ref(id)); } return rsp; }
QObject *qmp_dispatch(QObject *request) { Error *err = NULL; QObject *ret; QDict *rsp; ret = do_qmp_dispatch(request, &err); rsp = qdict_new(); if (err) { qdict_put_obj(rsp, "error", error_get_qobject(err)); error_free(err); } else if (ret) { qdict_put_obj(rsp, "return", ret); } else { QDECREF(rsp); return NULL; } return QOBJECT(rsp); }