aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 5d68a5d6fc..5c003731e2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -635,6 +635,13 @@ static void monitor_data_init(Monitor *mon)
static void monitor_data_destroy(Monitor *mon)
{
+ if (mon->chr) {
+ qemu_chr_add_handlers(mon->chr, NULL, NULL, NULL, NULL);
+ }
+ if (monitor_is_qmp(mon)) {
+ json_message_parser_destroy(&mon->qmp.parser);
+ }
+ g_free(mon->rs);
QDECREF(mon->outbuf);
qemu_mutex_destroy(&mon->out_lock);
}
@@ -4196,6 +4203,19 @@ void monitor_init(CharDriverState *chr, int flags)
qemu_mutex_unlock(&monitor_lock);
}
+void monitor_cleanup(void)
+{
+ Monitor *mon, *next;
+
+ qemu_mutex_lock(&monitor_lock);
+ QLIST_FOREACH_SAFE(mon, &mon_list, entry, next) {
+ QLIST_REMOVE(mon, entry);
+ monitor_data_destroy(mon);
+ g_free(mon);
+ }
+ qemu_mutex_unlock(&monitor_lock);
+}
+
static void bdrv_password_cb(void *opaque, const char *password,
void *readline_opaque)
{