mirror of https://github.com/xemu-project/xemu.git
Monitor: Drop the print disabling mechanism
We can ignore calls to monitor_vprintf() in QMP mode and use monitor_puts() directly in monitor_json_emitter(). This allows us to drop this ugly hack. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
b4475aa2b3
commit
b8b08266bd
18
monitor.c
18
monitor.c
|
@ -120,7 +120,6 @@ struct mon_fd_t {
|
||||||
|
|
||||||
typedef struct MonitorControl {
|
typedef struct MonitorControl {
|
||||||
QObject *id;
|
QObject *id;
|
||||||
int print_enabled;
|
|
||||||
JSONMessageParser parser;
|
JSONMessageParser parser;
|
||||||
int command_mode;
|
int command_mode;
|
||||||
} MonitorControl;
|
} MonitorControl;
|
||||||
|
@ -226,16 +225,18 @@ static void monitor_puts(Monitor *mon, const char *str)
|
||||||
|
|
||||||
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
if (!mon)
|
if (!mon)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mon->mc && !mon->mc->print_enabled) {
|
if (monitor_ctrl_mode(mon)) {
|
||||||
qemu_error_new(QERR_UNDEFINED_ERROR);
|
qemu_error_new(QERR_UNDEFINED_ERROR);
|
||||||
} else {
|
return;
|
||||||
char buf[4096];
|
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
||||||
monitor_puts(mon, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
monitor_puts(mon, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitor_printf(Monitor *mon, const char *fmt, ...)
|
void monitor_printf(Monitor *mon, const char *fmt, ...)
|
||||||
|
@ -306,9 +307,8 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)
|
||||||
json = qobject_to_json(data);
|
json = qobject_to_json(data);
|
||||||
assert(json != NULL);
|
assert(json != NULL);
|
||||||
|
|
||||||
mon->mc->print_enabled = 1;
|
qstring_append_chr(json, '\n');
|
||||||
monitor_printf(mon, "%s\n", qstring_get_str(json));
|
monitor_puts(mon, qstring_get_str(json));
|
||||||
mon->mc->print_enabled = 0;
|
|
||||||
|
|
||||||
QDECREF(json);
|
QDECREF(json);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue