mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
Merge remote-tracking branch 'qmp/queue/qmp' into staging
* qmp/queue/qmp: (48 commits) target-ppc: add implementation of query-cpu-definitions (v2) target-i386: add implementation of query-cpu-definitions (v2) qapi: add query-cpu-definitions command (v2) compiler: add macro for GCC weak symbols qapi: add query-machines command qapi: mark QOM commands stable qmp: introduce device-list-properties command qmp: add SUSPEND_DISK event qmp: qmp-events.txt: add missing doc for the SUSPEND event qmp: qmp-events.txt: put events in alphabetical order qmp: emit the WAKEUP event when the guest is put to run qmp: don't emit the RESET event on wakeup from S3 scripts: qapi-commands.py: qmp-commands.h: include qdict.h docs: writing-qmp-commands.txt: update error section error, qerror: drop QDict member qerror: drop qerror_table and qerror_format() error, qerror: pass desc string to error calls error: drop error_get_qobject()/error_set_qobject() qemu-ga: switch to the new error format on the wire qmp: switch to the new error format on the wire ...
This commit is contained in:
commit
633decd711
35 changed files with 691 additions and 1121 deletions
84
monitor.c
84
monitor.c
|
@ -172,41 +172,11 @@ struct Monitor {
|
|||
CPUArchState *mon_cpu;
|
||||
BlockDriverCompletionFunc *password_completion_cb;
|
||||
void *password_opaque;
|
||||
#ifdef CONFIG_DEBUG_MONITOR
|
||||
int print_calls_nr;
|
||||
#endif
|
||||
QError *error;
|
||||
QLIST_HEAD(,mon_fd_t) fds;
|
||||
QLIST_ENTRY(Monitor) entry;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_DEBUG_MONITOR
|
||||
#define MON_DEBUG(fmt, ...) do { \
|
||||
fprintf(stderr, "Monitor: "); \
|
||||
fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
|
||||
|
||||
static inline void mon_print_count_inc(Monitor *mon)
|
||||
{
|
||||
mon->print_calls_nr++;
|
||||
}
|
||||
|
||||
static inline void mon_print_count_init(Monitor *mon)
|
||||
{
|
||||
mon->print_calls_nr = 0;
|
||||
}
|
||||
|
||||
static inline int mon_print_count_get(const Monitor *mon)
|
||||
{
|
||||
return mon->print_calls_nr;
|
||||
}
|
||||
|
||||
#else /* !CONFIG_DEBUG_MONITOR */
|
||||
#define MON_DEBUG(fmt, ...) do { } while (0)
|
||||
static inline void mon_print_count_inc(Monitor *mon) { }
|
||||
static inline void mon_print_count_init(Monitor *mon) { }
|
||||
static inline int mon_print_count_get(const Monitor *mon) { return 0; }
|
||||
#endif /* CONFIG_DEBUG_MONITOR */
|
||||
|
||||
/* QMP checker flags */
|
||||
#define QMP_ACCEPT_UNKNOWNS 1
|
||||
|
||||
|
@ -299,8 +269,6 @@ void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
|||
if (!mon)
|
||||
return;
|
||||
|
||||
mon_print_count_inc(mon);
|
||||
|
||||
if (monitor_ctrl_mode(mon)) {
|
||||
return;
|
||||
}
|
||||
|
@ -385,16 +353,26 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)
|
|||
QDECREF(json);
|
||||
}
|
||||
|
||||
static QDict *build_qmp_error_dict(const QError *err)
|
||||
{
|
||||
QObject *obj;
|
||||
|
||||
obj = qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %p } }",
|
||||
ErrorClass_lookup[err->err_class],
|
||||
qerror_human(err));
|
||||
|
||||
return qobject_to_qdict(obj);
|
||||
}
|
||||
|
||||
static void monitor_protocol_emitter(Monitor *mon, QObject *data)
|
||||
{
|
||||
QDict *qmp;
|
||||
|
||||
trace_monitor_protocol_emitter(mon);
|
||||
|
||||
qmp = qdict_new();
|
||||
|
||||
if (!monitor_has_error(mon)) {
|
||||
/* success response */
|
||||
qmp = qdict_new();
|
||||
if (data) {
|
||||
qobject_incref(data);
|
||||
qdict_put_obj(qmp, "return", data);
|
||||
|
@ -404,9 +382,7 @@ static void monitor_protocol_emitter(Monitor *mon, QObject *data)
|
|||
}
|
||||
} else {
|
||||
/* error response */
|
||||
qdict_put(mon->error->error, "desc", qerror_human(mon->error));
|
||||
qdict_put(qmp, "error", mon->error->error);
|
||||
QINCREF(mon->error->error);
|
||||
qmp = build_qmp_error_dict(mon->error);
|
||||
QDECREF(mon->error);
|
||||
mon->error = NULL;
|
||||
}
|
||||
|
@ -456,6 +432,7 @@ static const char *monitor_event_names[] = {
|
|||
[QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
|
||||
[QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
|
||||
[QEVENT_SUSPEND] = "SUSPEND",
|
||||
[QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
|
||||
[QEVENT_WAKEUP] = "WAKEUP",
|
||||
[QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
|
||||
};
|
||||
|
@ -3874,8 +3851,6 @@ void monitor_set_error(Monitor *mon, QError *qerror)
|
|||
if (!mon->error) {
|
||||
mon->error = qerror;
|
||||
} else {
|
||||
MON_DEBUG("Additional error report at %s:%d\n",
|
||||
qerror->file, qerror->linenr);
|
||||
QDECREF(qerror);
|
||||
}
|
||||
}
|
||||
|
@ -3889,36 +3864,7 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
|
|||
* Action: Report an internal error to the client if in QMP.
|
||||
*/
|
||||
qerror_report(QERR_UNDEFINED_ERROR);
|
||||
MON_DEBUG("command '%s' returned failure but did not pass an error\n",
|
||||
cmd->name);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_MONITOR
|
||||
if (!ret && monitor_has_error(mon)) {
|
||||
/*
|
||||
* If it returns success, it must not have passed an error.
|
||||
*
|
||||
* Action: Report the passed error to the client.
|
||||
*/
|
||||
MON_DEBUG("command '%s' returned success but passed an error\n",
|
||||
cmd->name);
|
||||
}
|
||||
|
||||
if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) {
|
||||
/*
|
||||
* Handlers should not call Monitor print functions.
|
||||
*
|
||||
* Action: Ignore them in QMP.
|
||||
*
|
||||
* (XXX: we don't check any 'info' or 'query' command here
|
||||
* because the user print function _is_ called by do_info(), hence
|
||||
* we will trigger this check. This problem will go away when we
|
||||
* make 'query' commands real and kill do_info())
|
||||
*/
|
||||
MON_DEBUG("command '%s' called print functions %d time(s)\n",
|
||||
cmd->name, mon_print_count_get(mon));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void handle_user_command(Monitor *mon, const char *cmdline)
|
||||
|
@ -4447,8 +4393,6 @@ static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd,
|
|||
int ret;
|
||||
QObject *data = NULL;
|
||||
|
||||
mon_print_count_init(mon);
|
||||
|
||||
ret = cmd->mhandler.cmd_new(mon, params, &data);
|
||||
handler_audit(mon, cmd, ret);
|
||||
monitor_protocol_emitter(mon, data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue