aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-01-27 00:49:13 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-06-02 11:33:53 +0400
commit1ce2610c106d925387669b3133fc18ea986f0476 (patch)
treebd08c41941ea2235cabde4c02739f6ca52ff07d7 /chardev
parenta9b1ca38c2b1f062f22d4847e3b4c848d0fb84c3 (diff)
downloadqemu-1ce2610c106d925387669b3133fc18ea986f0476.zip
qemu-1ce2610c106d925387669b3133fc18ea986f0476.tar.gz
qemu-1ce2610c106d925387669b3133fc18ea986f0476.tar.bz2
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>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-fe.c5
-rw-r--r--chardev/char-mux.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 341221d..3f90f05 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -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;
}
}
diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index 106c682..08570b9 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -266,7 +266,7 @@ static void char_mux_finalize(Object *obj)
be->chr = NULL;
}
}
- qemu_chr_fe_deinit(&d->chr);
+ qemu_chr_fe_deinit(&d->chr, false);
}
void mux_chr_set_handlers(Chardev *chr, GMainContext *context)