static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob, Error **errp) { const char *exec_key = NULL; const QDictEntry *ent; const char *arg_name; const QObject *arg_obj; QDict *dict; dict = qobject_to(QDict, request); if (!dict) { error_setg(errp, "QMP input must be a JSON object"); return NULL; } for (ent = qdict_first(dict); ent; ent = qdict_next(dict, ent)) { arg_name = qdict_entry_key(ent); arg_obj = qdict_entry_value(ent); if (!strcmp(arg_name, "execute") || (!strcmp(arg_name, "exec-oob") && allow_oob)) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { error_setg(errp, "QMP input member '%s' must be a string", arg_name); return NULL; } if (exec_key) { error_setg(errp, "QMP input member '%s' clashes with '%s'", arg_name, exec_key); return NULL; } exec_key = arg_name; } else if (!strcmp(arg_name, "arguments")) { if (qobject_type(arg_obj) != QTYPE_QDICT) { error_setg(errp, "QMP input member 'arguments' must be an object"); return NULL; } } else if (!strcmp(arg_name, "id")) { continue; } else { error_setg(errp, "QMP input member '%s' is unexpected", arg_name); return NULL; } } if (!exec_key) { error_setg(errp, "QMP input lacks member 'execute'"); return NULL; } return dict; }
static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) { const QDictEntry *ent; const char *arg_name; const QObject *arg_obj; bool has_exec_key = false; QDict *dict = NULL; if (qobject_type(request) != QTYPE_QDICT) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "request is not a dictionary"); return NULL; } dict = qobject_to_qdict(request); for (ent = qdict_first(dict); ent; ent = qdict_next(dict, ent)) { arg_name = qdict_entry_key(ent); arg_obj = qdict_entry_value(ent); if (!strcmp(arg_name, "execute")) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute", "string"); return NULL; } has_exec_key = true; } else if (strcmp(arg_name, "arguments")) { error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name); return NULL; } } if (!has_exec_key) { error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute"); return NULL; } return dict; }
void update_insn_class_info(const char* class_idx, const char* insn) { // Assuming class indexes are positive const QDictEntry* pentry; int64_t idx= -1; assert(class_info != NULL); pentry = qdict_first(class_info); do { QObject* temp = qdict_entry_value(pentry); QDict* pdict = qobject_to_qdict(temp); idx = qdict_get_int(pdict, "idx"); const char * str = qdict_get_str(pdict, "class_name"); if(strcmp(str, class_idx) == 0) break; idx = -1; pentry = qdict_next(class_info, pentry); } while(pentry != NULL); assert(insn_map != NULL); if(idx != -1) get_map_entry(insn)->instruction_type = idx; }