Revision 030db6e8
b/monitor.c | ||
---|---|---|
3390 | 3390 |
return search_dispatch_table(mon_cmds, cmdname); |
3391 | 3391 |
} |
3392 | 3392 |
|
3393 |
static const mon_cmd_t *qmp_find_query_cmd(const char *info_item) |
|
3394 |
{ |
|
3395 |
return search_dispatch_table(info_cmds, info_item); |
|
3396 |
} |
|
3397 |
|
|
3393 | 3398 |
static const mon_cmd_t *monitor_parse_command(Monitor *mon, |
3394 | 3399 |
const char *cmdline, |
3395 | 3400 |
QDict *qdict) |
... | ... | |
4329 | 4334 |
return input_dict; |
4330 | 4335 |
} |
4331 | 4336 |
|
4337 |
static void qmp_call_query_cmd(Monitor *mon, const mon_cmd_t *cmd) |
|
4338 |
{ |
|
4339 |
QObject *ret_data = NULL; |
|
4340 |
|
|
4341 |
if (monitor_handler_is_async(cmd)) { |
|
4342 |
qmp_async_info_handler(mon, cmd); |
|
4343 |
if (monitor_has_error(mon)) { |
|
4344 |
monitor_protocol_emitter(mon, NULL); |
|
4345 |
} |
|
4346 |
} else { |
|
4347 |
cmd->mhandler.info_new(mon, &ret_data); |
|
4348 |
if (ret_data) { |
|
4349 |
monitor_protocol_emitter(mon, ret_data); |
|
4350 |
qobject_decref(ret_data); |
|
4351 |
} |
|
4352 |
} |
|
4353 |
} |
|
4354 |
|
|
4332 | 4355 |
static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) |
4333 | 4356 |
{ |
4334 | 4357 |
int err; |
... | ... | |
4336 | 4359 |
QDict *input, *args; |
4337 | 4360 |
const mon_cmd_t *cmd; |
4338 | 4361 |
Monitor *mon = cur_mon; |
4339 |
const char *cmd_name, *info_item;
|
|
4362 |
const char *cmd_name, *query_cmd;
|
|
4340 | 4363 |
|
4364 |
query_cmd = NULL; |
|
4341 | 4365 |
args = input = NULL; |
4342 | 4366 |
|
4343 | 4367 |
obj = json_parser_parse(tokens, NULL); |
... | ... | |
4363 | 4387 |
} |
4364 | 4388 |
|
4365 | 4389 |
/* |
4366 |
* XXX: We need this special case until we get info handlers |
|
4367 |
* converted into 'query-' commands |
|
4390 |
* XXX: We need this special case until QMP has its own dispatch table |
|
4368 | 4391 |
*/ |
4369 | 4392 |
if (compare_cmd(cmd_name, "info")) { |
4370 | 4393 |
qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); |
4371 | 4394 |
goto err_out; |
4372 |
} else if (strstart(cmd_name, "query-", &info_item)) { |
|
4373 |
cmd = monitor_find_command("info"); |
|
4374 |
qdict_put_obj(input, "arguments", |
|
4375 |
qobject_from_jsonf("{ 'item': %s }", info_item)); |
|
4395 |
} else if (strstart(cmd_name, "query-", &query_cmd)) { |
|
4396 |
cmd = qmp_find_query_cmd(query_cmd); |
|
4376 | 4397 |
} else { |
4377 | 4398 |
cmd = monitor_find_command(cmd_name); |
4378 | 4399 |
} |
... | ... | |
4395 | 4416 |
goto err_out; |
4396 | 4417 |
} |
4397 | 4418 |
|
4398 |
if (monitor_handler_is_async(cmd)) { |
|
4419 |
if (query_cmd) { |
|
4420 |
qmp_call_query_cmd(mon, cmd); |
|
4421 |
} else if (monitor_handler_is_async(cmd)) { |
|
4399 | 4422 |
err = qmp_async_cmd_handler(mon, cmd, args); |
4400 | 4423 |
if (err) { |
4401 | 4424 |
/* emit the error response */ |
Also available in: Unified diff