Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
char: clean up remaining chardevs when leaving
Browse files Browse the repository at this point in the history
This helps to remove various chardev resources leaks when leaving qemu.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
elmarco authored and bonzini committed Jun 29, 2016
1 parent 25f0d2a commit c1111a2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qemu-char.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

0 comments on commit c1111a2

Please sign in to comment.