aboutsummaryrefslogtreecommitdiff
path: root/chardev/char-mux.c
diff options
context:
space:
mode:
authorRoman Penyaev <r.peniaev@gmail.com>2024-10-14 17:24:07 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2024-10-15 12:26:01 +0400
commit327993f180e22f7f18b8693bd2381b74b1f971a6 (patch)
treed9a67d37156a9bcdec3d2f4f0895b64e82608d42 /chardev/char-mux.c
parent005b6d511f23e0c2b69b4c7353defaa48c24853d (diff)
downloadqemu-327993f180e22f7f18b8693bd2381b74b1f971a6.zip
qemu-327993f180e22f7f18b8693bd2381b74b1f971a6.tar.gz
qemu-327993f180e22f7f18b8693bd2381b74b1f971a6.tar.bz2
chardev/mux: implement detach of frontends from mux
With bitset management now it becomes feasible to implement the logic of detaching frontends from multiplexer. Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20241014152408.427700-8-r.peniaev@gmail.com>
Diffstat (limited to 'chardev/char-mux.c')
-rw-r--r--chardev/char-mux.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index 4fc619b..bda5c45 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -290,10 +290,10 @@ static void char_mux_finalize(Object *obj)
bit = -1;
while ((bit = find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX_MUX) {
CharBackend *be = d->backends[bit];
- if (be) {
- be->chr = NULL;
- }
+ be->chr = NULL;
+ d->backends[bit] = NULL;
}
+ d->mux_bitset = 0;
qemu_chr_fe_deinit(&d->chr, false);
}
@@ -332,6 +332,21 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
return true;
}
+bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
+{
+ unsigned int bit;
+
+ bit = find_next_bit(&d->mux_bitset, MAX_MUX, tag);
+ if (bit != tag) {
+ return false;
+ }
+
+ d->mux_bitset &= ~(1 << bit);
+ d->backends[bit] = NULL;
+
+ return true;
+}
+
void mux_set_focus(Chardev *chr, unsigned int focus)
{
MuxChardev *d = MUX_CHARDEV(chr);