QAPIEvent e;
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
- const char *event_name = QAPIEvent_lookup[e];
+ const char *event_name = QAPIEvent_str(e);
assert(event_name != NULL);
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
switch(format) {
case 'o':
- max_digits = (wsize * 8 + 2) / 3;
+ max_digits = DIV_ROUND_UP(wsize * 8, 3);
break;
default:
case 'x':
break;
case 'u':
case 'd':
- max_digits = (wsize * 8 * 10 + 32) / 33;
+ max_digits = DIV_ROUND_UP(wsize * 8 * 10, 33);
break;
case 'c':
wsize = 1;
}
len = strlen(str);
readline_set_completion_index(rs, len);
- for (i = 0; NetClientDriver_lookup[i]; i++) {
- add_completion_option(rs, str, NetClientDriver_lookup[i]);
+ for (i = 0; i < NET_CLIENT_DRIVER__MAX; i++) {
+ add_completion_option(rs, str, NetClientDriver_str(i));
}
}
len = strlen(str);
readline_set_completion_index(rs, len);
for (i = 0; i < Q_KEY_CODE__MAX; i++) {
- if (!strncmp(str, QKeyCode_lookup[i], len)) {
- readline_add_completion(rs, QKeyCode_lookup[i]);
+ if (!strncmp(str, QKeyCode_str(i), len)) {
+ readline_add_completion(rs, QKeyCode_str(i));
}
}
}
return;
}
readline_set_completion_index(rs, strlen(str));
- for (i = 0; WatchdogExpirationAction_lookup[i]; i++) {
- add_completion_option(rs, str, WatchdogExpirationAction_lookup[i]);
+ for (i = 0; i < WATCHDOG_EXPIRATION_ACTION__MAX; i++) {
+ add_completion_option(rs, str, WatchdogExpirationAction_str(i));
}
}
if (nb_args == 2) {
int i;
for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
- const char *name = MigrationCapability_lookup[i];
+ const char *name = MigrationCapability_str(i);
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
if (nb_args == 2) {
int i;
for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
- const char *name = MigrationParameter_lookup[i];
+ const char *name = MigrationParameter_str(i);
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
QDict *qdict = NULL;
Monitor *mon = cur_mon;
Error *err = NULL;
- QString *req_json;
req = json_parser_parse_err(tokens, NULL, &err);
if (!req && !err) {
qdict_del(qdict, "id");
} /* else will fail qmp_dispatch() */
- req_json = qobject_to_json(req);
- trace_handle_qmp_command(mon, qstring_get_str(req_json));
- QDECREF(req_json);
+ if (trace_event_get_state_backends(TRACE_HANDLE_QMP_COMMAND)) {
+ QString *req_json = qobject_to_json(req);
+ trace_handle_qmp_command(mon, qstring_get_str(req_json));
+ QDECREF(req_json);
+ }
rsp = qmp_dispatch(cur_mon->qmp.commands, req);
qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error");
if (qdict
&& !g_strcmp0(qdict_get_try_str(qdict, "class"),
- QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) {
+ QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) {
/* Provide a more useful error message */
qdict_del(qdict, "desc");
qdict_put_str(qdict, "desc", "Expecting capabilities negotiation"