Message ID | 1466105332-10285-2-git-send-email-marcandre.lureau@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 16, 2016 at 09:28:50PM +0200, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > This helps to remove various chardev resources leaks when leaving qemu. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > qemu-char.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel
diff --git a/qemu-char.c b/qemu-char.c index c926e9a..98dcd49 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -4541,6 +4541,15 @@ void qmp_chardev_remove(const char *id, Error **errp) qemu_chr_delete(chr); } +static void qemu_chr_cleanup(void) +{ + CharDriverState *chr; + + QTAILQ_FOREACH(chr, &chardevs, next) { + qemu_chr_delete(chr); + } +} + static void register_types(void) { register_char_driver("null", CHARDEV_BACKEND_KIND_NULL, NULL, @@ -4587,6 +4596,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);