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

@ -1678,9 +1678,6 @@ void gdb_exit(CPUArchState *env, int code)
{
GDBState *s;
char buf[4];
#ifndef CONFIG_USER_ONLY
Chardev *chr;
#endif
s = gdbserver_state;
if (!s) {
@ -1690,19 +1687,13 @@ void gdb_exit(CPUArchState *env, int code)
if (gdbserver_fd < 0 || s->fd < 0) {
return;
}
#else
chr = qemu_chr_fe_get_driver(&s->chr);
if (!chr) {
return;
}
#endif
snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
put_packet(s, buf);
#ifndef CONFIG_USER_ONLY
qemu_chr_fe_deinit(&s->chr);
object_unparent(OBJECT(chr));
qemu_chr_fe_deinit(&s->chr, true);
#endif
}
@ -2002,9 +1993,7 @@ int gdbserver_start(const char *device)
NULL, &error_abort);
monitor_init(mon_chr, 0);
} else {
if (qemu_chr_fe_get_driver(&s->chr)) {
object_unparent(OBJECT(qemu_chr_fe_get_driver(&s->chr)));
}
qemu_chr_fe_deinit(&s->chr, true);
mon_chr = s->mon_chr;
memset(s, 0, sizeof(GDBState));
s->mon_chr = mon_chr;