From nobody Sat Nov 23 23:28:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1728906291; cv=none; d=zohomail.com; s=zohoarc; b=Yng3N9Pn4qeuw6/QJ9ltmt4z1acBKEQGTDaS7YwLEeSKFfU9OPtO+h/GCE6olaYkaZf6j0gt2KntEfB4cnCNt2jmXwdxX2H0XNxz+5C5jLQW1aG1SPmELZjHOGOj/7KgPFc5Afj/0wevOpHCM4GEy+8yMLCNiAryxbYOJ2hCpOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906291; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=XjYNJJ1dYrUmsDzEmUe+V7cRkzd0WDVuJMYgHV7VGG8=; b=cZ27zteDGk1XQDpRII3SFRdjguZh97BZjEvEl06hToorRDTrBvbzt403AhvC+JACEJMkZGbyiYJNL8K2QzUulsxzMpzgSeGpw3iqZO/mr9cQDeoAJ9VHTDcwgt1rEuGQCdPf4w8RmdLYFogmnyX/AMu7Ey/wDzNcPGqbcTlvOmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728906291568733.745716373879; Mon, 14 Oct 2024 04:44:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUl-0006gW-65; Mon, 14 Oct 2024 07:44:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0JUY-0006dC-2f for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:02 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00057W-Np for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:01 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-539f2b95775so1101036e87.1 for ; Mon, 14 Oct 2024 04:43:52 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99fcb2765asm247764666b.64.2024.10.14.04.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906231; x=1729511031; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XjYNJJ1dYrUmsDzEmUe+V7cRkzd0WDVuJMYgHV7VGG8=; b=MonTXul8KcgyhhVwu/4OHP1VyiFcMjA45cxHPtCemXbkV4a4MZ97qa4oWqQ8PDnl01 GAaiqfdD6u1odpx+avtLrgWjc1GVQ5dx5s7xAzc20ZmTrL7QI3FFPEuygdciv5bWaKBd RfADloPZdZviMNsdBK1Fy+MRqkR2yoPy3YjeiM8hDy+usBLsCUdT5kg2X5ExwvkrC7eK J0STR3N2rQ/UlVkeKrM9+eetRn7MF4sY5EcE0wv74q/7aYOTaXDoFErE3jrO9jplD+ep GctqqMIkyYzDHVy8atIHmuoJqTnmm+By+lqMyiau4ycFwjs/15eseZUxIA8AVhAKvELJ tgtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906231; x=1729511031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XjYNJJ1dYrUmsDzEmUe+V7cRkzd0WDVuJMYgHV7VGG8=; b=f1GmaqlDc4BCl07I1QfPRkgPe4kZveUSWDRXeONECBc8HDlw5P8/FIYA7inig08FfG fN1l5Ze7OI6gUYU3P3cN5KGH0JDGpecBQm6PXSxnYo5yfLtP2lYBgfGmsS+0iiEPIcAP TzaMjgRWH4M6bO+7gKqxZickIEG81O4nVchzmUsmIkCzUQBitDF3XdKF4cziopxJC/2A TDFOzBRFC5T5/A/A33Bn15/LcVjTFa7spdNJAdzwqb34X02u3GQXCHLTJETT5qtyHQqP Q75sSgoy/59I25wiyNNpHy4qjvWxmMDkFRSuOaFxEo50Q3Jjfv8Vtu1V1VAJ7IYvaQeB NY0g== X-Forwarded-Encrypted: i=1; AJvYcCVQ3CcSGPwUAfL2t5NNxahLojjHlccPYZYtY8j1wekcGHm5ajTAwPiTgoNgJnRr+vKN1QTaeiBUNrZ1@nongnu.org X-Gm-Message-State: AOJu0Yxb6cNUuwAw5cVYc7bGUHwGI+EI+mrOx2GhVAO/KXpC4UO0J6XE d55q170HlSn5GncabV7e9j1oDNR/G1vbjmsItyFLdxfxzm0nl0aw X-Google-Smtp-Source: AGHT+IHJtJuvVhj6lvf5iIYuutgeA7fLoa6Z33wvidhJL8LGmxjPJRBfOxwafPBQSk9IMurG2SwCBA== X-Received: by 2002:a05:6512:220d:b0:539:8a50:6ee8 with SMTP id 2adb3069b0e04-539e57282b1mr3443460e87.57.1728906231089; Mon, 14 Oct 2024 04:43:51 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 7/8] chardev/mux: implement detach of frontends from mux Date: Mon, 14 Oct 2024 13:41:34 +0200 Message-Id: <20241014114135.389766-8-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014114135.389766-1-r.peniaev@gmail.com> References: <20241014114135.389766-1-r.peniaev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=r.peniaev@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1728906292578116600 With bitset management now it becomes feasible to implement the logic of detaching frontends from multiplexer. Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org --- chardev/char-fe.c | 2 +- chardev/char-mux.c | 20 +++++++++++++++++--- chardev/chardev-internal.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 3b8771ca2ac4..8ac6bebb6f74 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -225,7 +225,7 @@ void qemu_chr_fe_deinit(CharBackend *b, bool del) } if (CHARDEV_IS_MUX(b->chr)) { MuxChardev *d =3D MUX_CHARDEV(b->chr); - d->backends[b->tag] =3D NULL; + mux_chr_detach_frontend(d, b->tag); } if (del) { Object *obj =3D OBJECT(b->chr); diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 9c3cacb2fecd..649f8ff6ccbf 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -289,10 +289,10 @@ static void char_mux_finalize(Object *obj) bit =3D -1; while ((bit =3D find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX= _MUX) { CharBackend *be =3D d->backends[bit]; - if (be) { - be->chr =3D NULL; - } + be->chr =3D NULL; + d->backends[bit] =3D NULL; } + d->mux_bitset =3D 0; qemu_chr_fe_deinit(&d->chr, false); } =20 @@ -331,6 +331,21 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBacken= d *b, return true; } =20 +bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag) +{ + unsigned int bit; + + bit =3D find_next_bit(&d->mux_bitset, MAX_MUX, tag); + if (bit >=3D MAX_MUX) { + return false; + } + + d->mux_bitset &=3D ~(1 << bit); + d->backends[bit] =3D NULL; + + return true; +} + void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d =3D MUX_CHARDEV(chr); diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index b89aada5413b..853807f3cb88 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -61,6 +61,7 @@ DECLARE_INSTANCE_CHECKER(MuxChardev, MUX_CHARDEV, =20 bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, unsigned int *tag, Error **errp); +bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag); void mux_set_focus(Chardev *chr, unsigned int focus); void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event); =20 --=20 2.34.1