diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-06-16 21:28:50 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-29 16:49:41 +0200 |
commit | c1111a24a3358ecd2f17be7c8b117cfe8bc5e5f8 (patch) | |
tree | 5dcc55751141d6f4de38a58a161099dea31ced25 /qemu-char.c | |
parent | 25f0d2aa5e3d21caa1bc622b21368cc2e383f02c (diff) |
char: clean up remaining chardevs when leaving
This helps to remove various chardev resources leaks when leaving qemu.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1466105332-10285-2-git-send-email-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r-- | qemu-char.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c index 8575c54c98..b73969ddbd 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -4549,6 +4549,15 @@ void qmp_chardev_remove(const char *id, Error **errp) qemu_chr_delete(chr); } +static void qemu_chr_cleanup(void) +{ + CharDriverState *chr, *tmp; + + QTAILQ_FOREACH_SAFE(chr, &chardevs, next, tmp) { + qemu_chr_delete(chr); + } +} + static void register_types(void) { register_char_driver("null", CHARDEV_BACKEND_KIND_NULL, NULL, @@ -4595,6 +4604,8 @@ static void register_types(void) * is specified */ qemu_add_machine_init_done_notifier(&muxes_realize_notify); + + atexit(qemu_chr_cleanup); } type_init(register_types); |