From nobody Sat Nov 23 20:46:54 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=1728906351; cv=none; d=zohomail.com; s=zohoarc; b=XQ5cmSt8jpHPWF0PgcUOmNjnZNlg4fMLgWkSIxMTjnFec9bhNhGUVMSIH3w3+UtKF7uryoMmHBvubNhtFEErihwLfC0JCkdJRMAhG6yXs0cL3ZBspAucRCk789wpu7B3KibnMR7asNQDUwb6Cpc1xeKuXaRFdbI8VuDZmi7ZfTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906351; 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=QaYY9X9pUCStJ66Iupj9x96nWBsnt7lR9iGUBryB4Dk=; b=Q0Au/Xagj0bvUuJqKnD3iOP2oYkC6U26jdxBS60ErfCCtlBdRhGmw3tM9Rgq236+ZeImipJk2HodX3S94Mvy05KVQUlwp+N/XS08M/rMVT4AuF/RhqYT0JOE2toJcwtEJ9/LZQjXwTZASmzJqhoahOzELG8ecJvw6jVWAzTYu2A= 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 1728906351344119.78730897824562; Mon, 14 Oct 2024 04:45:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUX-0006d9-T1; Mon, 14 Oct 2024 07:44:02 -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 1t0JUU-0006cO-VB for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:43:59 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUJ-00056M-0D for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:43:48 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a9a0474e70eso192037266b.0 for ; Mon, 14 Oct 2024 04:43:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906225; x=1729511025; 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=QaYY9X9pUCStJ66Iupj9x96nWBsnt7lR9iGUBryB4Dk=; b=WlEXveOnqGqOt7egtrmFb/iIGlyX/65lCx0zEw+WMBYn51iNejmGCzrPmTZsm1FXXe O+UyZ3LfSz5+dIrTWZuNG2OqEWh4CFyZdS2yVXTRO9qiOwEOfMh19AL6+llXx8y+q/+x lpRburbI/fqXkXOcjbCNqUAzEWKoDbJ+t52UYqCdz4xJCf1MGYVVZfAgDN05SqcN3n+G ViPnFx/OMHNHp7CX5Igg/0wH8SwfbLJQ1l5giAznzw7MDraSOahcPUhugRVmdPtBBDEW S3KO9r/4NYUgBHX+1bxEG+w9w8H7SM3s8G1h2pJmAUOJ3zuognwFCjdb9BaseX+IUWNf Ow3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906225; x=1729511025; 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=QaYY9X9pUCStJ66Iupj9x96nWBsnt7lR9iGUBryB4Dk=; b=RVaCvccBAv1eiZ6IXLubYTW4B75TI2LBv5zU/hnRp26AhGCTTGqZnZnXXEmOUHZunc StJNe4Smp1CmagbYf53zIPfNYqpDIdg7goRfp9dCH10jHP2xNCqlmHwNMx+Xut311+qh kxD4gC4mURLrGD5PGAog3eq/oORNPxmu9LeLIzg/FAh2Mtb6XlB7l+9FG+sL8VEQ3Btc /ljy1N8XSTTQW/olxf74sLpJHlyyKFVjmYcGh0YkpaNybvnj9rkhPj8pv9skLM2JqD8Y 9xZ+/oWv7MaiE5x+2o70V0YyCjFLbpA6gH73amyiqWFcQC6S0s9RgQur8IAJP+Q9RzfQ JBpQ== X-Forwarded-Encrypted: i=1; AJvYcCX80TykRNwLSd18VMOCr8F/i5Uo4UD5O93LYlpGaele4owFI1+ezxP/p3wIxMb8eMJFr5ykJJvyCS6H@nongnu.org X-Gm-Message-State: AOJu0YxsWSJME0DvbARBrGFnw+1QQrXBdEIIXCQTjL7DdXgsiWxzOgVR dCmyFnKojBmLvLEUhULfBmq8oDaNzGUUIrlE4IdxNc2pVEUn8kYX X-Google-Smtp-Source: AGHT+IE4w50uuU7dEjW9unNDc65rOX7MfH3nc2sGkKI9teFEIjvZILC4zAQkr7N4hLss8n30Xxgmpg== X-Received: by 2002:a17:907:1b1f:b0:a99:e1a1:473f with SMTP id a640c23a62f3a-a99e3ea59ddmr811732366b.57.1728906224654; Mon, 14 Oct 2024 04:43:44 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 1/8] chardev/char: fix qemu_chr_is_busy() check Date: Mon, 14 Oct 2024 13:41:28 +0200 Message-Id: <20241014114135.389766-2-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::629; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x629.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: 1728906352520116600 `mux_cnt` struct member never goes negative or decrements, so mux chardev can be !busy only when there are no frontends attached. This patch fixes the always-true check. Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend") Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index c0cc52824b48..f54dc3a86286 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -333,7 +333,7 @@ static bool qemu_chr_is_busy(Chardev *s) { if (CHARDEV_IS_MUX(s)) { MuxChardev *d =3D MUX_CHARDEV(s); - return d->mux_cnt >=3D 0; + return d->mux_cnt > 0; } else { return s->be !=3D NULL; } --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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=1728906380; cv=none; d=zohomail.com; s=zohoarc; b=esaQcpGGTDwBMvO2hWAcK84YUvZXwrbjlRK6hDE4MEGt8qXT3Hp7gdlfD1MgZp072bjH6oqss0hMbXBktq0M/dqw2VpDgmZFVqLDIHdgbM9v4B6/UeGW5/jlEDrKEC4H9gYAT9FVYei96qVBvL4HvufeFzxPB1JArCac1SVfEUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906380; 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=7qO/4HKWHrVuc6GQ36ulz/Nn1mmzauBCzpX9YAoGCMM=; b=fikE7/cSd/L1YTeVTmTLkhqX/Z0tnh/+XPh19zF3ZMq3pwNld31bP3u7YxJNmirh9JAtGFYz1LHqTP0ah5bAchw4ikO2iXf8Gzdw7SzSweEY3rTPsA4tskQvqLuSHFf9X+wrp7/bodlUBoKshqopwBPHWL7trXI8X3omINH95YU= 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 1728906380178382.22681833694173; Mon, 14 Oct 2024 04:46:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUa-0006du-Rt; Mon, 14 Oct 2024 07:44:04 -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 1t0JUU-0006cQ-V4 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:43:59 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUJ-00056W-D6 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:43:49 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a99e3b3a411so323808166b.0 for ; Mon, 14 Oct 2024 04:43:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906225; x=1729511025; 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=7qO/4HKWHrVuc6GQ36ulz/Nn1mmzauBCzpX9YAoGCMM=; b=CNcCF0wuKZT6U2pq+SqtODHZYRZRDDfz05cG2H8pd5vn/deshGxjsXYV+JqLHDuzpF +tw0Hbd8AcwaWSgDK7dN4Jie8TkpXHkrk86Mb5kaYKkU7KAmcwj8CAUbIBBkh6rvUm/V TJKPPOP8l/0x7W0919l/0vkdO2wXEz2/8/tkfuGOiVqMTpjpxZBluS/FQcBmWHLOp6JZ YINofNaGkAvecHgcbYWu/vkfFYGn8LsH6z5jCRiT0M7PdZM4fqmHg5V6PRyDidpNeh51 dlAblyr/CKOhp71sqa5UeA3jTT7IJFj5QbgU9DB/wthzqbcVOm4pYsOoM/RuaUASeof+ 1t5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906225; x=1729511025; 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=7qO/4HKWHrVuc6GQ36ulz/Nn1mmzauBCzpX9YAoGCMM=; b=JqZhWJDZkA06788j5blfteraUoRCp2Ul1gurlsbdPMWnJxZ6K1mQzU+uCcdrRSUeot LIfcyYUXH2r4xqnhiIPVdjThokyKMxzNurMrS3Oh8M8Cf2vuaK9uZ+0zrWkWJf3O1Ypl lEZt0XFzg+hsU63JndoJO+nR2PEpMEtmq/s6VkZs7A0V3zEipIGGfEZ7mJ2d5qY2LQix IYY8U7q5Qk1+dgjXsYKCDObgjQk1BNDtDiWOntq2dsIu9g3ajTIVHtJLjsgrnyvS8xFo DwhySyOGbwZbzG/8b09Gz6Tmi7AKqie15AQccVWwMu3TEwmXesaLK/mpyPWN/XIDe34U xYlw== X-Forwarded-Encrypted: i=1; AJvYcCX4aKKcTLFs4ApYWMmnC+xu5u7PmM13G7MSiOjr+77C7WoWPeaR2faD1tF1BUxzi66thcDsPgjS+3aW@nongnu.org X-Gm-Message-State: AOJu0YyeePS9auYv5PyOgX8u4S7bFZQPf1bYRtM5FaY8mWH6Txj18/g0 gMh3dMhB54MTGB85FQ3k/bA2Sj1Vaeb02zazs3gy2/EaMC3HxH0hSfaQcg== X-Google-Smtp-Source: AGHT+IGB+9MUTxbiaPxJAsuIqO34C+VnrlUDm3BdJyxrV/If0tvsfYdH8W8LLj4VfCmk0P9dkqJs7Q== X-Received: by 2002:a17:906:794b:b0:a90:9fb5:2c43 with SMTP id a640c23a62f3a-a99b8a67042mr1106077566b.34.1728906225362; Mon, 14 Oct 2024 04:43:45 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 2/8] chardev/chardev-internal: remove unused `max_size` struct member Date: Mon, 14 Oct 2024 13:41:29 +0200 Message-Id: <20241014114135.389766-3-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::630; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x630.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: 1728906386703116600 Clean up forgotten leftovers. Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/chardev-internal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index 4e03af31476c..c3024b51fdda 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -40,7 +40,6 @@ struct MuxChardev { int focus; int mux_cnt; int term_got_escape; - int max_size; /* Intermediate input buffer catches escape sequences even if the currently active device is not accepting any input - but only until= it is full as well. */ --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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=1728906364; cv=none; d=zohomail.com; s=zohoarc; b=GnveGPUPRh3HKvwel8dxjG6EkTbkmFbGgHH7Inl3jpUg82Ox4P/HvXIhNsA5AkaTrPszWmSiBA8JBuTb3iHXYmh9UlWgebM4BAH6xjJ8fvUnBi2GuH082o+06S6zEZfYH2QoGXc2zhvwxkVTaqPyCOp53HvSm3tuSYPzTNJCR+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906364; 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=QKeU6Sst3mOvcdt2OZL+D4LtHqpR806Hah+uBtunjhM=; b=UNRsGEAaYUXZ3NSzTtBd1QOXHYssaxFxz1W6uJfIE/YRhgOLdZ9an1p+9XRFryQx/XKMT4GS0FbpWqtiVHsvxUqFXORDOEQB+Iik6YGw9p2LQDwn1TEC1KpxN1pe60q7q1obs4wC7yzq8mwIIhURa2uDEDuZETPu5fygHZ32+lg= 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 1728906364429629.8381010172058; Mon, 14 Oct 2024 04:46:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUa-0006dj-GL; Mon, 14 Oct 2024 07:44:04 -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 1t0JUW-0006cq-OK for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:00 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00056k-MG for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:00 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a994cd82a3bso623078066b.2 for ; Mon, 14 Oct 2024 04:43:48 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906227; x=1729511027; 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=QKeU6Sst3mOvcdt2OZL+D4LtHqpR806Hah+uBtunjhM=; b=IDkvsGCMFGzbIRRW3Obqdkw+svsn4s1yquSnc9hqpGuiOogFpqI/sA0cYdNpQehShX Sa/vRpzIImkALgLV+IChBRKcaOvKq3ms8+3XwdsNuanCyWGhuz8Z0c4JYCtyC9Iqg8gx YxIgTqF9q9SckAiuvt6+UZ/NXf63Qf2wWinE/UnYQmQ5ftP1pLKS8uKScmz2eTcBdDtG 9jn4JpY0vb557YiDLEOPtueos4n3EEKBBvol4/fvixfHUsWy0BY9bcFIu+xUAt+yLtCk az0gA2KDRCO5x2MSPVBDwf6vZ0Pi/FESOzsN9feiJfD6tZvEFjoQ4yQDr21/2PCmfO1G qYvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906227; x=1729511027; 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=QKeU6Sst3mOvcdt2OZL+D4LtHqpR806Hah+uBtunjhM=; b=mJonC7sLMT7Dk9HQaMETMXoG0lRnvpEJ50fa4AaF6Dy+PaqUQ4lkk59kJsqHbXDpZI yd4Ny7bqDvCYQb+xpMNBk22TprWjhMN/++l9lYMxbcZ2Xv3CI6zdK4YiHVMxprM+01OI uC1c7BBlGOwhKOWjh38EbfGBJWfwXiXauG59UA3nPjf2ELUVJyb5WRxKUR5y2SPDo7EL hqGntyscEj232RHR2OKRY6cn4VNtZmXNngW5yQAsiiUtnKgabmSMz5+ZCd8ccMCsk6VY 5C9dHeHuV1TYsVcnrWPc3nEOAzdQrEx6qMbKkLn7rGIGi+X21hDuRNBQlasEzPtsujKG YelQ== X-Forwarded-Encrypted: i=1; AJvYcCUgx10l2c+ljnfvIseZ7KpVQQTDmjwdZKWolQD8m1NvlUW1s4yrBb49vXUfZXbagNJfuMGMI2W3t5jr@nongnu.org X-Gm-Message-State: AOJu0Yxb04SmnIADktGHzyKCT52OPcBakhV5UkiiZP+fqXQXXwkFbT9f dPaFdZpgeIrss7Mo+nY37B4LMIPHHt+mqOIzLwWSiV7swCUYUsvklQIcAQ== X-Google-Smtp-Source: AGHT+IF20XS3rMdTFBDoqNVmpTk8olWOkaedW8omauTVzVXigYa9CsUsFbkXovYHWkRjVGQcwz9TUA== X-Received: by 2002:a17:906:99c4:b0:a99:5f16:3539 with SMTP id a640c23a62f3a-a99b8e9f11bmr1087525766b.0.1728906226629; Mon, 14 Oct 2024 04:43:46 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 3/8] chardev/mux: use bool type for `linestart` and `term_got_escape` Date: Mon, 14 Oct 2024 13:41:30 +0200 Message-Id: <20241014114135.389766-4-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::62e; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x62e.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: 1728906366627116600 Those are boolean variables, not signed integers. Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-mux.c | 10 +++++----- chardev/chardev-internal.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chardev/char-mux.c b/chardev/char-mux.c index ee2d47b20d9b..728596c6f346 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -73,11 +73,11 @@ static int mux_chr_write(Chardev *chr, const uint8_t *b= uf, int len) * qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all(&d->chr, (uint8_t *)buf1, strlen(buf1)); - d->linestart =3D 0; + d->linestart =3D false; } ret +=3D qemu_chr_fe_write(&d->chr, buf + i, 1); if (buf[i] =3D=3D '\n') { - d->linestart =3D 1; + d->linestart =3D true; } } } @@ -145,7 +145,7 @@ static void mux_chr_be_event(Chardev *chr, QEMUChrEvent= event) static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch) { if (d->term_got_escape) { - d->term_got_escape =3D 0; + d->term_got_escape =3D false; if (ch =3D=3D term_escape_char) { goto send_char; } @@ -175,11 +175,11 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d,= int ch) case 't': d->timestamps =3D !d->timestamps; d->timestamps_start =3D -1; - d->linestart =3D 0; + d->linestart =3D false; break; } } else if (ch =3D=3D term_escape_char) { - d->term_got_escape =3D 1; + d->term_got_escape =3D true; } else { send_char: return 1; diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index c3024b51fdda..975c16de803e 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -39,7 +39,7 @@ struct MuxChardev { CharBackend chr; int focus; int mux_cnt; - int term_got_escape; + bool term_got_escape; /* Intermediate input buffer catches escape sequences even if the currently active device is not accepting any input - but only until= it is full as well. */ @@ -49,7 +49,7 @@ struct MuxChardev { int timestamps; =20 /* Protected by the Chardev chr_write_lock. */ - int linestart; + bool linestart; int64_t timestamps_start; }; typedef struct MuxChardev MuxChardev; --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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=1728906364; cv=none; d=zohomail.com; s=zohoarc; b=G5AFsw5klXYWLD3NIGLFVatpO2LaXlkKjpW//pYUDJlqAp+4RrRssSQZt0DxMxILdNBQNVbPk682ZMviEYwNT7huhRBuFAa/WKyu+LpZlUoiJFyc79qha0qMIdEcs8f4+J5z05fd0g6Z0XkcCg3bC5RKwVONIeUy59YmAosf4jQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906364; 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=p4v/fGpWXC16nH9NFmBVigHbrDSRKiF2Owvw6nK5eQE=; b=kPyGZ0whWChg0TLqr5YO5vlnAQ6hl/4ygf+9jl91Gno1+X6T8/lBnGxF76tZPYPOlAZpj4oeL5Z9TAoytz/uE+gb02VVIkKEzYLK5qoEtzm6k1iEEQRumLRrFYPQjpZG+K4KqbWOCHWykG+tZKcIdUkJ2C7EJ+CLMguF1t8pPlg= 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 1728906364324457.2363867141106; Mon, 14 Oct 2024 04:46:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUo-0006hH-DJ; Mon, 14 Oct 2024 07:44:18 -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 1t0JUZ-0006dK-GL for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:03 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00056u-RH for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:03 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a9a0084f703so217660366b.3 for ; Mon, 14 Oct 2024 04:43:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906227; x=1729511027; 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=p4v/fGpWXC16nH9NFmBVigHbrDSRKiF2Owvw6nK5eQE=; b=jrr0kZD/lyYBcrFIkJiNqWKfItihGvxUU6bKrJb43b2Z5b9paV2g9ksr5jPPBnkJ8N bTigD5S+8OsEqpgDER0BDojcbv1bFV4Fyc4xmpjjAhmeWGcVq5ZEpCjXwVtRvXT4QVM+ zzsMlsk4tYlYGlrDr1oOX3wvlWhPCLBwHWEHbVetDQdIlx3HtlOZrE6Y/O5mMmocBBru xpNK2XUL1TykDrQo7o1X+5cex2YSivy/aBg6w/p4zsyq8izsJ0JG+HQ2/payo8IE8hlh xHFRsh0Y8gWP5nxws/A1jwozBNT2iVzfYdc5K1xYMM1ANmmI5UzQoO+uNZ7lTRq9BXfr Vs4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906227; x=1729511027; 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=p4v/fGpWXC16nH9NFmBVigHbrDSRKiF2Owvw6nK5eQE=; b=t/l8TVYwrYGrhlK+0cajSp+ox81DHEYR9dDT8fQELyC6djd8uLJ7UsX5sP2K/DTAzu ylYgK83ODYucxcO205zptjicyvewUDxOYT7RvS5vM0UVHPjsIgS5E71L+vBGulvJ2L15 3S+OD65d6jIVIapiPv7+XB/b40Cl0He5eZIPJk64bbhY43hH/vx8x/kesphHFUwe3b5p lXIablfVGJyG5qHOZA8otITpJ7uQdk0Y+N16qG53bUEkhGPRfEw1/Srut0fG4Kv1M/BE rwXkqaZQTJco4+LuILXWhGcQ+MjguhBCQY4Z0beiy9y48E25NTDZS7IkCyhsm7bVRmSO ussA== X-Forwarded-Encrypted: i=1; AJvYcCWD23DPxUq4tILGoyg0A/Qx9kndew3sk3w/qwSHTN3T7MY9eFqb1pKdxgTNXgg43uQk794uVSs+PtKx@nongnu.org X-Gm-Message-State: AOJu0Yz+i2Td8PRWS13lo8ak4571knK7NPmVsZQnDHkjpdb5u+TwSfqr /XYe4yfIiUOmbtaIGWS9irAD7gFlnuTkO+r8aSD/VlyxL/3njUGuToqx9Q== X-Google-Smtp-Source: AGHT+IGuKrv9zQvSY/gd7IWgsxMe6RRlKlqo74WCfd8oZIc4XmEiYbuLPcnnyGlUsj2Ztc8RLhJqhQ== X-Received: by 2002:a17:907:6e94:b0:a99:fe71:bd76 with SMTP id a640c23a62f3a-a99fe71bebamr536086866b.34.1728906227096; Mon, 14 Oct 2024 04:43:47 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 4/8] chardev/mux: convert size members to unsigned int Date: Mon, 14 Oct 2024 13:41:31 +0200 Message-Id: <20241014114135.389766-5-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::62f; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x62f.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: 1728906364654116600 There is no sense to keep `focus`, `mux_cnt`, `prod`, `cons` and `tag` variables as signed, those represent either size, either position in array, which both are unsigned. `focus` member of `MuxChardev` is kept signed, because initially set to -1. Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fe.c | 2 +- chardev/char-mux.c | 10 +++++----- chardev/chardev-internal.h | 8 ++++---- include/chardev/char-fe.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index b214ba3802b1..69b47d16bdfa 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -191,7 +191,7 @@ bool qemu_chr_fe_backend_open(CharBackend *be) =20 bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp) { - int tag =3D 0; + unsigned int tag =3D 0; =20 if (s) { if (CHARDEV_IS_MUX(s)) { diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 728596c6f346..b2d7abf2fc01 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -124,7 +124,8 @@ static void mux_print_help(Chardev *chr) } } =20 -static void mux_chr_send_event(MuxChardev *d, int mux_nr, QEMUChrEvent eve= nt) +static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr, + QEMUChrEvent event) { CharBackend *be =3D d->backends[mux_nr]; =20 @@ -242,7 +243,7 @@ static void mux_chr_read(void *opaque, const uint8_t *b= uf, int size) void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event) { MuxChardev *d =3D MUX_CHARDEV(chr); - int i; + unsigned int i; =20 if (!muxes_opened) { return; @@ -275,7 +276,7 @@ static GSource *mux_chr_add_watch(Chardev *s, GIOCondit= ion cond) static void char_mux_finalize(Object *obj) { MuxChardev *d =3D MUX_CHARDEV(obj); - int i; + unsigned int i; =20 for (i =3D 0; i < d->mux_cnt; i++) { CharBackend *be =3D d->backends[i]; @@ -300,11 +301,10 @@ static void mux_chr_update_read_handlers(Chardev *chr) chr->gcontext, true, false); } =20 -void mux_set_focus(Chardev *chr, int focus) +void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d =3D MUX_CHARDEV(chr); =20 - assert(focus >=3D 0); assert(focus < d->mux_cnt); =20 if (d->focus !=3D -1) { diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index 975c16de803e..ab93f6ea1720 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -38,14 +38,14 @@ struct MuxChardev { CharBackend *backends[MAX_MUX]; CharBackend chr; int focus; - int mux_cnt; + unsigned int mux_cnt; bool term_got_escape; /* Intermediate input buffer catches escape sequences even if the currently active device is not accepting any input - but only until= it is full as well. */ unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE]; - int prod[MAX_MUX]; - int cons[MAX_MUX]; + unsigned int prod[MAX_MUX]; + unsigned int cons[MAX_MUX]; int timestamps; =20 /* Protected by the Chardev chr_write_lock. */ @@ -59,7 +59,7 @@ DECLARE_INSTANCE_CHECKER(MuxChardev, MUX_CHARDEV, #define CHARDEV_IS_MUX(chr) \ object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) =20 -void mux_set_focus(Chardev *chr, int focus); +void mux_set_focus(Chardev *chr, unsigned int focus); void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event); =20 Object *get_chardevs_root(void); diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 3310449eaf03..8ef05b3dd095 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -20,7 +20,7 @@ struct CharBackend { IOReadHandler *chr_read; BackendChangeHandler *chr_be_change; void *opaque; - int tag; + unsigned int tag; bool fe_is_open; }; =20 --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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=1728906332; cv=none; d=zohomail.com; s=zohoarc; b=BNVKU/CBu+aRyBvCGgzPH5MSiSMYMqydKfQhe2XGIKBcIlCb0gN1eo1+xjyfIRbJ3mxl/E/Luaj63tnI0LpC25DzzuLm3eNuG6sSq1uYFsHAjcko5O5yas4mcXJVpi8JfRQnG66426fjN2TQE0mHpXFI1TtrdE8c/ysBHf6SX80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906332; 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=D9lTfUtZ9ffHIdlW/Te4mim8Q2HJoGfSrfyIQQdPKJM=; b=F3gEL3nng7gcjHDEGLWs/5qucs8qBiHaUlQcL8dMt7+pg1Zg6eGUbfLKfUUZHkNOqc0x4aAKOb++hQ1QtJYJRpHGJU1CzbM+dtoIba/UW24S2ppJ0xmxmcW8OOuV26xXr5NOuajRja5FKgipXJjgDBipj8J0JkwZNiESY2158tM= 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 1728906332822499.85636403509034; Mon, 14 Oct 2024 04:45:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUc-0006el-KF; Mon, 14 Oct 2024 07:44:06 -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 1t0JUW-0006cp-O0 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:00 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00057C-Q2 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:00 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a9a0084f703so217664066b.3 for ; Mon, 14 Oct 2024 04:43:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906229; x=1729511029; 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=D9lTfUtZ9ffHIdlW/Te4mim8Q2HJoGfSrfyIQQdPKJM=; b=NzgsyX5dLUwYCmcYw2E0Q1WeBN+earf08JAvjmYtsH/zRH9rxdNuHgs3w2AHaX1fYD 8YS77X7LYKu7fq+lGvDbbunxKjo4uXXMvd+Q7/anT2BBIPSaXuj7WA3eoypFHNjxkw/l p6Iqvh4dEPPJHY+6jtMVZALrPcUJkCkKD9Zza0AosXniTxF+V9v+LzWm86jsSJ1Ew9wS eMRC/2Ucl3G3CVoqPVO2CiRGlqZRmZ1y7sqSEdLoFhAIrt5cw6UXsRo6iay1fEy9j+0M TGx1DkiCvyf8fdUC3+eOQrQOnTQD5ODxmurhXojja46K00uYQZpwnqMEjyHr49g2jwVy YKFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906229; x=1729511029; 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=D9lTfUtZ9ffHIdlW/Te4mim8Q2HJoGfSrfyIQQdPKJM=; b=FDuhLTvy9N8zCTf1m2YAPmJ14o9O9+plpkSAheJcRHHL/L1WwuUiJ3A7fZk155ZL17 Lg0DccuEn86lojOgLZHfScdlRQP6d+7ELzwUXarokcodY70WHMsist/d1s3xnrA7SVw4 u80dTJW7SxAlq4e7NgSu2LLP0EWhbRnhy7aNa0XZ2SzhaDfSlsnytlK+4MRIroA4gd6A xBDctklYUQgrjInlkS8iT7nJPsezb74IDrZLMNH13cZgRbU3Li8MtKecjSiRGm3RQXsQ XqEkdIXA88YLiQL9alipBymUWKwcRALyNJZZjdYwgEWm4tDg1uRFIoSO+TIOw8rYAUSs UlIg== X-Forwarded-Encrypted: i=1; AJvYcCUsDOpAyne6vK4JTdcKTss3OQeYYOzmTJCjLRcdme4jdwo1qFK1/skJlW5uC/mwRENGIbA4F7LJJ+Jc@nongnu.org X-Gm-Message-State: AOJu0Yy3QYTLEtdS7SBEINmClTtqGUd9lv1cnBYhrEtIG3obLMKB2zv+ JMm8RU3nJHdgYxUpXAd77kuSNf3qZGhyF5lsonoVBzwirzHvf2AZ X-Google-Smtp-Source: AGHT+IFEIsY2OzlhWBWtNgrzm2vSr4x+7qG2KiOu5J+IHU7lw77MndlM5b+23i7vlASUXfEAuq6pEw== X-Received: by 2002:a17:907:6e89:b0:a9a:6d7:9c4 with SMTP id a640c23a62f3a-a9a06d70be9mr398799066b.12.1728906228690; Mon, 14 Oct 2024 04:43:48 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 5/8] chardev/mux: introduce `mux_chr_attach_frontend() call Date: Mon, 14 Oct 2024 13:41:32 +0200 Message-Id: <20241014114135.389766-6-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::631; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x631.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: 1728906334520116600 Move away logic which attaches frontend device to a mux from `char-fe.c` to actual `char-mux.c` implementation and make it a separate function. No logic changes are made. Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fe.c | 9 +-------- chardev/char-mux.c | 17 +++++++++++++++++ chardev/chardev-internal.h | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 69b47d16bdfa..3b8771ca2ac4 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -197,16 +197,9 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Erro= r **errp) if (CHARDEV_IS_MUX(s)) { MuxChardev *d =3D MUX_CHARDEV(s); =20 - if (d->mux_cnt >=3D MAX_MUX) { - error_setg(errp, - "too many uses of multiplexed chardev '%s'" - " (maximum is " stringify(MAX_MUX) ")", - s->label); + if (!mux_chr_attach_frontend(d, b, &tag, errp)) { return false; } - - d->backends[d->mux_cnt] =3D b; - tag =3D d->mux_cnt++; } else if (s->be) { error_setg(errp, "chardev '%s' is already in use", s->label); return false; diff --git a/chardev/char-mux.c b/chardev/char-mux.c index b2d7abf2fc01..9294f955462e 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -301,6 +301,23 @@ static void mux_chr_update_read_handlers(Chardev *chr) chr->gcontext, true, false); } =20 +bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, + unsigned int *tag, Error **errp) +{ + if (d->mux_cnt >=3D MAX_MUX) { + error_setg(errp, + "too many uses of multiplexed chardev '%s'" + " (maximum is " stringify(MAX_MUX) ")", + d->parent.label); + return false; + } + + d->backends[d->mux_cnt] =3D b; + *tag =3D d->mux_cnt++; + + 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 ab93f6ea1720..8126ce180690 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -59,6 +59,8 @@ DECLARE_INSTANCE_CHECKER(MuxChardev, MUX_CHARDEV, #define CHARDEV_IS_MUX(chr) \ object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) =20 +bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, + unsigned int *tag, Error **errp); void mux_set_focus(Chardev *chr, unsigned int focus); void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event); =20 --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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=1728906300; cv=none; d=zohomail.com; s=zohoarc; b=JPPz1LKpiO2hN7oXxE0V1jznzZyQOdaC5RZ1tc8Tc6z1X/PRotZyqgdyqlyrCbmyia+bnpPY0Erxjjqt614Gazh+ySDqfBQ0wqM1Hif2kOcQWoNeYjuAxEwcO+F5lNPsT8kErcMef9iXIH+IzwWjCX2mkIDCKul/Qdt/46h2FCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906300; 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=ynoC6ZNN5x0Gxdxw4knRNVaB7HA31bvhIUGL+XlLnyY=; b=Y3gI/aomUjqyDzHOiL+cQMg2U1Q9y7Xwjs2vVHqDDNnVVwXIpYMYrrFdKrJucKUNAHBa2IsgBEPl0IACS3Lod7JDkvGTBmAcKynoG1uCdxBV2TkZu1Gu6umKgRng39ScnChy8u5oHhm5uZztFLjaY4b3cBw3TgJeKUvezg6k9no= 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 1728906300555714.1341999295873; Mon, 14 Oct 2024 04:45:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUg-0006fI-3z; Mon, 14 Oct 2024 07:44:10 -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-0006dF-7B for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:02 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00057K-PT for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:01 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a99e3b3a411so323818166b.0 for ; Mon, 14 Oct 2024 04:43:50 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906229; x=1729511029; 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=ynoC6ZNN5x0Gxdxw4knRNVaB7HA31bvhIUGL+XlLnyY=; b=nJeClDOvpRNfu1RjFnqKJtNgfUBRMMOKdTgykwG+zzy1l8gZGYLI7S45fQRQCQJEjz on1BRbi08Mj86pILQZ1EIlPCTwhR/SxFOn0LOfrOx4jEWjNyvJtEyZ+JZz+B6MdCkMxv 2/9Lo+WyVGkH0YCGsSJn0B1/0qYhZhPWMPlrlqOQY+jWSYmwKaRO9BHKSIE/jMYHQ3Y3 dIB0X35lWAhxYPde6iYo6lPh6XMSRsY4BZDgA/Y+SWuadEmdCPo2+EUnJR4MfEAap4Gj VQcxgqFiHS7p/c7xU7gpRqUeNGod8me9TXfRrMD5ADKwMBc8cYx+VA9G4/w/G+YuWR9F gIsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906229; x=1729511029; 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=ynoC6ZNN5x0Gxdxw4knRNVaB7HA31bvhIUGL+XlLnyY=; b=GaqxK1Ssomy8ztPcZpdC4KQarZkb1DYa39l7nINoTSa0V+yJY6S+qDcGBDecicCLHJ cwNx233hdufRMdf8s8A9cKuvv3O3m494ipNgCrxzuNYFXMTCZ4DoWY8YoLC6gEYECmyY NWXHq60eriHkcqVHepTBBxNxiywDMRqAhPpFa3AhkyzosGUI6LWdL8iQgtZZAE3IgFax eUCzNfT7Kq1A2UuJ8htTFrXqjjYDDe50iyGpbzRxcuUMDbAimzMTGRYLIKqj6jtK6JkS NBe5BKhvENGQlPpQiYNzW+t2H5JlNak03bPCrWsZryNJRxmHcSRvUGcNi2DVVraXmM/n 5m5w== X-Forwarded-Encrypted: i=1; AJvYcCUdcNLxIMzwiJdYfvDA1cwq+ljHtEcVn1TaM7SM8H1nUiwN2bpJl1mKqJZmrPIg92XT9ExPRinvhwdA@nongnu.org X-Gm-Message-State: AOJu0YxjEbZrbr/BRL29KSXtWAYJlzp2fuLdEmk1o2fnYnKPNx6K/Vzk r6lTRAGgoCX15iprl8j+SNkkM1nPKGv8WKHw0dCEamXYvePG0TlP X-Google-Smtp-Source: AGHT+IHwC2xVd5zH5TEvQBkcwn0IkJHngCZH9dFrZ649JIze5rlb28Q9KhL+srVEN3Fz6McPIvQ05g== X-Received: by 2002:a17:906:4fd1:b0:a99:4e74:52aa with SMTP id a640c23a62f3a-a99b89f3f6bmr932651666b.33.1728906229237; Mon, 14 Oct 2024 04:43:49 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 6/8] chardev/mux: switch mux frontends management to bitset Date: Mon, 14 Oct 2024 13:41:33 +0200 Message-Id: <20241014114135.389766-7-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::632; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x632.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: 1728906302566116600 Frontends can be attached and detached during run-time (although detach is not implemented, but will follow). Counter variable of muxes is not enough for proper attach/detach management, so this patch implements bitset: if bit is set for the `mux_bitset` variable, then frontend device can be found in the `backend` array (yes, huge confusion with backend and frontends names). Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-mux.c | 41 +++++++++++++++++++++++++------------- chardev/char.c | 2 +- chardev/chardev-internal.h | 2 +- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 9294f955462e..9c3cacb2fecd 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -26,6 +26,7 @@ #include "qapi/error.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/bitops.h" #include "chardev/char.h" #include "sysemu/block-backend.h" #include "qapi/qapi-commands-control.h" @@ -168,12 +169,19 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d,= int ch) case 'b': qemu_chr_be_event(chr, CHR_EVENT_BREAK); break; - case 'c': - assert(d->mux_cnt > 0); /* handler registered with first fe */ + case 'c': { + unsigned int bit; + + /* Handler registered with first fe */ + assert(d->mux_bitset !=3D 0); /* Switch to the next registered device */ - mux_set_focus(chr, (d->focus + 1) % d->mux_cnt); + bit =3D find_next_bit(&d->mux_bitset, MAX_MUX, d->focus + 1); + if (bit >=3D MAX_MUX) { + bit =3D find_next_bit(&d->mux_bitset, MAX_MUX, 0); + } + mux_set_focus(chr, bit); break; - case 't': + } case 't': d->timestamps =3D !d->timestamps; d->timestamps_start =3D -1; d->linestart =3D false; @@ -243,15 +250,16 @@ static void mux_chr_read(void *opaque, const uint8_t = *buf, int size) void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event) { MuxChardev *d =3D MUX_CHARDEV(chr); - unsigned int i; + int bit; =20 if (!muxes_opened) { return; } =20 /* Send the event to all registered listeners */ - for (i =3D 0; i < d->mux_cnt; i++) { - mux_chr_send_event(d, i, event); + bit =3D -1; + while ((bit =3D find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX= _MUX) { + mux_chr_send_event(d, bit, event); } } =20 @@ -276,10 +284,11 @@ static GSource *mux_chr_add_watch(Chardev *s, GIOCond= ition cond) static void char_mux_finalize(Object *obj) { MuxChardev *d =3D MUX_CHARDEV(obj); - unsigned int i; + int bit; =20 - for (i =3D 0; i < d->mux_cnt; i++) { - CharBackend *be =3D d->backends[i]; + 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; } @@ -304,7 +313,10 @@ static void mux_chr_update_read_handlers(Chardev *chr) bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, unsigned int *tag, Error **errp) { - if (d->mux_cnt >=3D MAX_MUX) { + unsigned int bit; + + bit =3D find_next_zero_bit(&d->mux_bitset, MAX_MUX, 0); + if (bit >=3D MAX_MUX) { error_setg(errp, "too many uses of multiplexed chardev '%s'" " (maximum is " stringify(MAX_MUX) ")", @@ -312,8 +324,9 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend= *b, return false; } =20 - d->backends[d->mux_cnt] =3D b; - *tag =3D d->mux_cnt++; + d->mux_bitset |=3D (1 << bit); + d->backends[bit] =3D b; + *tag =3D bit; =20 return true; } @@ -322,7 +335,7 @@ void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d =3D MUX_CHARDEV(chr); =20 - assert(focus < d->mux_cnt); + assert(find_next_bit(&d->mux_bitset, MAX_MUX, focus) < MAX_MUX); =20 if (d->focus !=3D -1) { mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT); diff --git a/chardev/char.c b/chardev/char.c index f54dc3a86286..a1722aa076d9 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -333,7 +333,7 @@ static bool qemu_chr_is_busy(Chardev *s) { if (CHARDEV_IS_MUX(s)) { MuxChardev *d =3D MUX_CHARDEV(s); - return d->mux_cnt > 0; + return d->mux_bitset !=3D 0; } else { return s->be !=3D NULL; } diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index 8126ce180690..b89aada5413b 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -37,8 +37,8 @@ struct MuxChardev { Chardev parent; CharBackend *backends[MAX_MUX]; CharBackend chr; + unsigned long mux_bitset; int focus; - unsigned int mux_cnt; bool term_got_escape; /* Intermediate input buffer catches escape sequences even if the currently active device is not accepting any input - but only until= it --=20 2.34.1 From nobody Sat Nov 23 20:46:54 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 Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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 From nobody Sat Nov 23 20:46:54 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=1728906350; cv=none; d=zohomail.com; s=zohoarc; b=RMvWwAfmH9MTeAFL+SJK7d/eqYeOyFCFg6XdLaBzFWByVm/Z2ZiJP6TMlRmooajl2HfU3PcsAd3JrMZgj1GZCAfTt5zL6Do3X+u1IfLE+ngGC+uyEGFgLPFNazAj79s4mqE00YPnz/QLHr1Gz4/YRrsugt/SXk6XyhNflOxyzjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728906350; 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=Twyv6YldhETnLvxZDkBVahrdEIkG4B6Hw1qzwu/nBjU=; b=IAp2NwRhY0LKFvQbVM1MQjtN9KRJOAGFG0skk+4rwmxRKD/I1GvV6qTac6a9Q51iiUU5e6sGXZtl8s9TVMzRqCz+WMNAL//Yv8Am8Z8WpyvpYFvg3gV9ychNlERaP4Cy7NKW/t11JMacq3QmJ6Y8yQK5XsKuTIVzwmmXe88u57E= 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 172890635095725.015792339687096; Mon, 14 Oct 2024 04:45:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0JUn-0006hB-Bc; Mon, 14 Oct 2024 07:44:17 -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-0006dD-31 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:02 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0JUU-00057Y-Qi for qemu-devel@nongnu.org; Mon, 14 Oct 2024 07:44:01 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5c94dd7e1c0so3907004a12.0 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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 04:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728906232; x=1729511032; 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=Twyv6YldhETnLvxZDkBVahrdEIkG4B6Hw1qzwu/nBjU=; b=Vz3CAVBo8BxFALYD/1nC0nE1F9RJqR3UuIgO8lZOfs50tld28l46K4Z8GKKr5eyMdU t2qe8Vzp3FlHaBH3/qh17xndMN/D0KVwEVL6y1Za/+Cpx1cQnRdd+VbAgspnn/8LEkX+ pVSJs4IqsNXd8B5ZmJ/zHsDCQzUMUn5VYxggKC3+u/4yOyPhGHC/8U+6WS1V08E5qOLO 7XdBYw2D1zxHpNqbiigelPEpavo0ZilQWGIqWyv16orGzyYIqewsEtDay1pWIHTWs7B1 Fie4BRrMVPkEfOEKUPqPdqbA/MhRZGp5fv1UrjKKQYvGxQOop4ikR4zyhVge9pfMwgWD E9YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728906232; x=1729511032; 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=Twyv6YldhETnLvxZDkBVahrdEIkG4B6Hw1qzwu/nBjU=; b=XW6lLcOsrw57cvW5wSvfvDxsUE2QDJ4bG33KdbL2VkKX6zBpVkM7m4MZfciS5jm/Gi RQADF1IXwAN96vFN/GBl4EapdiwKZhf25a9p1o6k+0IgbrhMPo6a9/w4aLbIiV4XI4GG jyJ8+6ik8Rgp8HCvxBSUSNBdm4bm+BwXOZ65gzRuoLv58A1p5/NTrUtZN+i924P/ZJ9o 9jQNzvU7OZdyn5pSmY5SgvTUfxontiUG9slgWEDcIHoNW8HKzEjDg+tkw5px0rYDdvmM yST5FcLfq6Be3xT6EpiJgrlsv2S6UogjktE06AFhOYo/+rHVOTEiChGejGfhZKSDonP7 tHsg== X-Forwarded-Encrypted: i=1; AJvYcCV6yWibw/BQgvmUlpDD7umwNzkSLXa4LmrtHtxpl+zLVN+fEHb7IbyJi3QSXcJPrMsax8Vst8TBOMxb@nongnu.org X-Gm-Message-State: AOJu0YyKMQVzociLNEAun7W6VSewniGh7fRj8uHpR1J7UCGPgfho+Xi4 lhUDVdKt8JqlmLwjDVALlLkBbFlQkXyI4K5UWE8Uf38dddQy+j7S X-Google-Smtp-Source: AGHT+IHMxOLYo5Hs9T1CLmrtnrsaqrE3a+Ue2Oc6y0E0YO1QVi6rszYnCN5rzQYiizMBrwPjjJxjZA== X-Received: by 2002:a17:907:e6cc:b0:a86:94e2:2a47 with SMTP id a640c23a62f3a-a99e3b5a86dmr683236066b.15.1728906231750; 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 8/8] tests/unit/test-char: implement a few mux remove test cases Date: Mon, 14 Oct 2024 13:41:35 +0200 Message-Id: <20241014114135.389766-9-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::533; envelope-from=r.peniaev@gmail.com; helo=mail-ed1-x533.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: 1728906352545116600 This patch tests: 1. feasibility of removing mux which does not have frontends attached or frontends were prior detached. 2. inability to remove mux which has frontends attached (mux is "busy") Signed-off-by: Roman Penyaev Cc: "Marc-Andr=C3=A9 Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/unit/test-char.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index f273ce522612..2837dbb863a8 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -1,6 +1,7 @@ #include "qemu/osdep.h" #include =20 +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/module.h" #include "qemu/option.h" @@ -184,6 +185,21 @@ static void char_mux_test(void) char *data; FeHandler h1 =3D { 0, false, 0, false, }, h2 =3D { 0, false, 0, false,= }; CharBackend chr_be1, chr_be2; + Error *error =3D NULL; + + /* Create mux and chardev to be immediately removed */ + opts =3D qemu_opts_create(qemu_find_opts("chardev"), "mux-label", + 1, &error_abort); + qemu_opt_set(opts, "backend", "ringbuf", &error_abort); + qemu_opt_set(opts, "size", "128", &error_abort); + qemu_opt_set(opts, "mux", "on", &error_abort); + chr =3D qemu_chr_new_from_opts(opts, NULL, &error_abort); + g_assert_nonnull(chr); + qemu_opts_del(opts); + + /* Remove just created mux and chardev */ + qmp_chardev_remove("mux-label", &error_abort); + qmp_chardev_remove("mux-label-base", &error_abort); =20 opts =3D qemu_opts_create(qemu_find_opts("chardev"), "mux-label", 1, &error_abort); @@ -334,7 +350,13 @@ static void char_mux_test(void) g_free(data); =20 qemu_chr_fe_deinit(&chr_be1, false); - qemu_chr_fe_deinit(&chr_be2, true); + + error =3D NULL; + qmp_chardev_remove("mux-label", &error); + g_assert_cmpstr(error_get_pretty(error), =3D=3D, "Chardev 'mux-label' = is busy"); + + qemu_chr_fe_deinit(&chr_be2, false); + qmp_chardev_remove("mux-label", &error_abort); } =20 =20 --=20 2.34.1