[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/20] QMP: Disable monitor print functions
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 15/20] QMP: Disable monitor print functions |
Date: |
Thu, 26 Nov 2009 22:59:05 -0200 |
We still have handlers which will call monitor print functions
in several places. Usually to report errors.
If they do this when we are in control mode, we will be emitting
garbage to our clients.
To avoid this problem, this commit adds a way to disable those
functions. If any of them is called when in control mode, we will
emit a generic error.
Although this is far from the perfect solution, it guarantees
that only JSON is sent to Clients.
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index 89115a6..a056503 100644
--- a/monitor.c
+++ b/monitor.c
@@ -98,6 +98,7 @@ struct mon_fd_t {
typedef struct MonitorControl {
QObject *id;
+ int print_enabled;
JSONMessageParser parser;
} MonitorControl;
@@ -186,9 +187,13 @@ static void monitor_puts(Monitor *mon, const char *str)
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
{
- char buf[4096];
- vsnprintf(buf, sizeof(buf), fmt, ap);
- monitor_puts(mon, buf);
+ if (mon->mc && !mon->mc->print_enabled) {
+ qemu_error_new(QERR_UNDEFINED_ERROR);
+ } else {
+ char buf[4096];
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ monitor_puts(mon, buf);
+ }
}
void monitor_printf(Monitor *mon, const char *fmt, ...)
@@ -272,7 +277,10 @@ static void monitor_json_emitter(Monitor *mon, const
QObject *data)
json = qobject_to_json(data);
assert(json != NULL);
+ mon->mc->print_enabled = 1;
monitor_printf(mon, "%s\n", qstring_get_str(json));
+ mon->mc->print_enabled = 0;
+
QDECREF(json);
}
--
1.6.6.rc0.50.gaf06e
- [Qemu-devel] [PATCH 05/20] monitor: Rename monitor_handle_command(), (continued)
- [Qemu-devel] [PATCH 05/20] monitor: Rename monitor_handle_command(), Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 06/20] monitor: Introduce 'info commands', Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 07/20] QError: Add errors needed by QMP, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 08/20] QMP: Initial support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 09/20] QMP: Output support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 10/20] QMP: do_info() checks, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 11/20] QMP: Input support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 12/20] QMP: Allow 'query-' commands, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 13/20] QMP: Asynchronous events infrastructure, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 14/20] QMP: Introduce basic asynchronous events, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 15/20] QMP: Disable monitor print functions,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 16/20] QMP: Introduce README file, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 17/20] QMP: Introduce specification, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 18/20] QMP: Introduce qmp-events.txt, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 19/20] QMP: Introduce qmp-shell, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 20/20] QMP: Introduce vm-info, Luiz Capitulino, 2009/11/26