char: make chr_fe_deinit() optionaly delete backend

This simplifies removing a backend for a frontend user (no need to
retrieve the associated driver and separate delete call etc).

NB: many frontends have questionable handling of ending a chardev. They
should probably delete the backend to prevent broken reusage.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
Marc-André Lureau 2017-01-27 00:49:13 +04:00
parent a9b1ca38c2
commit 1ce2610c10
16 changed files with 34 additions and 58 deletions

View file

@ -211,7 +211,7 @@ unavailable:
return false;
}
void qemu_chr_fe_deinit(CharBackend *b)
void qemu_chr_fe_deinit(CharBackend *b, bool del)
{
assert(b);
@ -224,6 +224,9 @@ void qemu_chr_fe_deinit(CharBackend *b)
MuxChardev *d = MUX_CHARDEV(b->chr);
d->backends[b->tag] = NULL;
}
if (del) {
object_unparent(OBJECT(b->chr));
}
b->chr = NULL;
}
}