From patchwork Mon Oct 14 15:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBB04D18129 for ; Mon, 14 Oct 2024 15:28:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxl-0006G5-46; Mon, 14 Oct 2024 11:26:25 -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 1t0Mxb-0006EV-VY for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:17 -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 1t0MxZ-0000vB-2E for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:14 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a9a1b71d7ffso85833366b.1 for ; Mon, 14 Oct 2024 08:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919571; x=1729524371; 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=FbX3/CUWJXb07XxPUSz0qAYWJ4C/mAjdr3fE8509XcYtqv1tXU2kJvEZA/5gfIBo6Y +QTZVc/Kmlyn9nMgoLudRWeTh3x8eqP+drjKggpIjtPzyd0R7fsz0hM05O1iuUQjdMe4 Ga7Ky5e6088uGUtie6YXE1ppJk2dUVSfvXWiSFMV/AfvJSFqTq6H/ErMxP7yMYw7CsM8 Ayel2IKcTmmF7iZ+X0fiaQECH/ICChWgjgyrCblvMlOVxGTj7HkGkmh2H3dcTU1Jk1/A lOisBVTBA/tDuGZweBNbui9NwG6UQTl3rM4uDD30jOUFzKouJ9bUJmEci6Gip3JXM3rw MyRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919571; x=1729524371; 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=KW1Vedcsq50Hl+1xhl9cGHi3gp4DU3OUoLUxIGS/3jNV4WlgS7FAPLPsJNaQXfsBJk Izwuk7/fyfBtHMyvv2iS9M+gz4kBqv63tWggnocSzaPWQfk36qUuMPB+tx1CQCRzQkCt MsZq70PFeLiB7o3NT0OWYWdEP7aTgJ9ior6U5bhUfzqOYQGaYOsvw3dU0eGiEg/uG8L5 v3n/nZPbaGhcl6weyHjeBklSfPZo23ao6XXWd4UalCQ0DFJq0qEt77gZgb1bKUdxJL+e fRHFyZrTYgkD8sN3V350BtGklmVJU28/myZnaLkEpt8g6X33QgIyqIZr/cdSSfNOJFix kJmQ== X-Forwarded-Encrypted: i=1; AJvYcCXpiGzhYorlXMsEqhPovHpuJDWHy/ket/njGdUt9hrYUmyfpePw6mGp2+3Ev0GHmmO4uVYu2i7p+5IE@nongnu.org X-Gm-Message-State: AOJu0YxrJ4k3NPzp7RxD+eA6/AGS6mdzVCs+15AZv/B43JcaAX5wKOdP 0bzum/V9Tmwu2BSj4gALDsAm4BkCH3o0LyZLnFcLZX/cC0urVO1DWakP6g== X-Google-Smtp-Source: AGHT+IHhinpAKBW8vGpg7qbPB9tX9QFXI2Kt7wpctCW6olsndY28fNtMmaG3cAD0OYHvuVjlUtrSqw== X-Received: by 2002:a17:907:9806:b0:a99:497f:317 with SMTP id a640c23a62f3a-a99b95fb02bmr976014266b.62.1728919571168; Mon, 14 Oct 2024 08:26:11 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:10 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 1/8] chardev/char: fix qemu_chr_is_busy() check Date: Mon, 14 Oct 2024 17:24:01 +0200 Message-Id: <20241014152408.427700-2-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org `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é Lureau" Cc: qemu-devel@nongnu.org --- 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 = MUX_CHARDEV(s); - return d->mux_cnt >= 0; + return d->mux_cnt > 0; } else { return s->be != NULL; } From patchwork Mon Oct 14 15:24:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91754D1812A for ; Mon, 14 Oct 2024 15:27:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxk-0006G2-W7; Mon, 14 Oct 2024 11:26:25 -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 1t0Mxh-0006Ez-Qd for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:23 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0MxZ-0000vE-RS for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:16 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-37d4ac91d97so3823346f8f.2 for ; Mon, 14 Oct 2024 08:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919572; x=1729524372; 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=CtarFoZbgg2jyd1mPrDYklVrhA3Mp1hIU2xqNvGKmzCY+Pag2Uk8Z2blO0fID7pRyI 8bQLTaYvbkVd+MjUKXZI5UaN6EuXNJ+KP8AboCnkJkWeUphAb8fC+eBKJCfPN98WoBo2 +h2UzpP8ad/OsDdhp+u7ldZMJ6cRKze8cKIzkFuaIBszMEsk+Ak3HeoYq6WpNzS2+5Ys BSIiIg+mv3Et33sO+OVAihczwasPKXulaezHn3Mj04lGLsSVgu6zo4XHiBkT+3WQ2MND tBUNGEiR1Mb6MvkTmnc/AxYHrdiitMwKbknYLw1U9+ncgadsYftw1CMtDRPnthmQh0SU 6LHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919572; x=1729524372; 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=G+gKKcnE1HhyS51ua7rNF7fYBZ2pvYHYcEmhnPSaUGcyLdfsITtwtFjHGNC9NUFU4P hNaUDH1IhjemjYQ3UjK7dH84nlQYVhkbnq3kd82KUfjigXw38+eD3hOo7IX0/KrxZxop da7hx7uLQylxHXlrePUxLIhfxAVvnVr5Ye4spNI39xHDdLuT6WE2OLI0MTN3AdUhpTO9 wgRYf/T05uwDtIQaKr0K4Td8tmgAOIBtwI1wqvhC61mkW0w9MISNDJ889ZHLCHW0DDgo T3iYHClqLrlaa9UdZx5WqsIE2hUdDXB3mHUJ85zPmg0jB0ObR7pEiqYwTUPAPj4kxW0O FyJQ== X-Forwarded-Encrypted: i=1; AJvYcCUIK3CYkfj9Wlr+PUYq4h7fX0FKl4Vs7IVfN0nhycu07TGO0AUaY57JPrRAwkwGCWfLSGjlgDP3OxnZ@nongnu.org X-Gm-Message-State: AOJu0Yxq+/XvmdT0coS0KpnoFnD2ki6oQM8Rtb1Otfnz4lEoLPP76Ohh 5XqAvlY0A2tEtR2BnTThKC2ztAYyrXUubSqwzq2sNs9U+ct2+yrN X-Google-Smtp-Source: AGHT+IF+ivIgMofxyM1n+FLoNmRJtFRgrfpTFcdNKheNl4E3/jec6DDMLCdx7DTj3ctmPebozXnIUA== X-Received: by 2002:adf:ecca:0:b0:37d:2ea4:bfcc with SMTP id ffacd0b85a97d-37d5ff4abc9mr7451308f8f.13.1728919571672; Mon, 14 Oct 2024 08:26:11 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:11 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 2/8] chardev/chardev-internal: remove unused `max_size` struct member Date: Mon, 14 Oct 2024 17:24:02 +0200 Message-Id: <20241014152408.427700-3-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=r.peniaev@gmail.com; helo=mail-wr1-x433.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Clean up forgotten leftovers. Signed-off-by: Roman Penyaev Cc: "Marc-André Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Clément Mathieu--Drif --- 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. */ From patchwork Mon Oct 14 15:24:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31962D18129 for ; Mon, 14 Oct 2024 15:27:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxk-0006Fn-AT; Mon, 14 Oct 2024 11:26:24 -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 1t0Mxj-0006FF-8y for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:23 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxb-0000vM-Nw for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:17 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-539e1543ab8so4276286e87.2 for ; Mon, 14 Oct 2024 08:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919573; x=1729524373; 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=iXwL8QzXU653ORChLABm6U8ob9MLpPYcGPdYao4B6txAVd9WYJ4b/DfqCHLmTRTh1e l3ryTbB7IkgURb8cU1cb1FCXulP06pTRYgJNY0lug4UQcLB2trV2Vib5frueg1WKI3Fe eyMm1w/aEC8YPz+btBxtuH4IDJz9NuQie7EsRWXco2SFKnxFMWRTGlzxmAiGrWDWXxHl EhmpEsrZEJmJfvvgT4hSpgXk+qEJJNR+Nuwzo4XAbBzG0G5bYb/Hcf5DdDHWijXm81kS iANyu1IaLXbfLqOrfJUsCspzRrqG69n/9EHUm5PLVpX5jAyuaHyZzplfYPyU9Spl/X+C xKqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919573; x=1729524373; 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=a7igiki5qNmHMoIECMPkmdxRNCw9814EyqVYh1bT/Qg69fQkC8fYwDkJw66mUDBGoX MJtE/WxRCmQV2VSQh0pVFhri5xslHiNZoCF+cpuAt9E+Lr9k95nRSXIVdarpirXS+bMm +9cxEKov/jsS1+QCqMyUPh0grUOYJg2aL8HVVcN3AcG7Zcu4o/65Oq6cew9Q7fyyNjft Fehd0cWjr5KdgrTM4viuPTw3vl05QnlmWK2Vg5dxCNLXwxGSjwEXIae8Rg+VNj/ShKm3 D/ee5lKNlZOg5n4NELQw6a46PXAnuPYhxG/aAPDBPMQ/hoBFoW+OMThXaZSFCpSw9FbY 5S0g== X-Forwarded-Encrypted: i=1; AJvYcCUQlA7uuSxtcszXjAgmN3UKIMvE8JZXD9SKcxo6odqNyUeaGJaX7HZI19Z/et2oKyXDVXf7MKg5IZHz@nongnu.org X-Gm-Message-State: AOJu0Ywd03wN+PvSex8v3Y2iFQG/8F3MDyPZoX9ITOdljZWFWeFIvKu+ WzNmu01UzH0vzLA62CFh9zZFMVTeRBnfY8DeB2AEEYDV6mc/jjQN X-Google-Smtp-Source: AGHT+IE4ciKO/NO3MojLJ1CjA0IiED4eFypqBKo96jGXOkBCU95BAuF/yVtTjSpONmh7THlS58IcwA== X-Received: by 2002:a05:6512:33cd:b0:538:96ce:f2ed with SMTP id 2adb3069b0e04-539e54d7759mr4127106e87.10.1728919572324; Mon, 14 Oct 2024 08:26:12 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:11 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 3/8] chardev/mux: use bool type for `linestart` and `term_got_escape` Date: Mon, 14 Oct 2024 17:24:03 +0200 Message-Id: <20241014152408.427700-4-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=r.peniaev@gmail.com; helo=mail-lf1-x12f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Those are boolean variables, not signed integers. Signed-off-by: Roman Penyaev Cc: "Marc-André Lureau" Cc: qemu-devel@nongnu.org Reviewed-by: Clément Mathieu--Drif --- 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 *buf, 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 = 0; + d->linestart = false; } ret += qemu_chr_fe_write(&d->chr, buf + i, 1); if (buf[i] == '\n') { - d->linestart = 1; + d->linestart = 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 = 0; + d->term_got_escape = false; if (ch == 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 = !d->timestamps; d->timestamps_start = -1; - d->linestart = 0; + d->linestart = false; break; } } else if (ch == term_escape_char) { - d->term_got_escape = 1; + d->term_got_escape = 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; /* Protected by the Chardev chr_write_lock. */ - int linestart; + bool linestart; int64_t timestamps_start; }; typedef struct MuxChardev MuxChardev; From patchwork Mon Oct 14 15:24:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE0F8D18128 for ; Mon, 14 Oct 2024 15:27:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxm-0006Gm-OE; Mon, 14 Oct 2024 11:26:26 -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 1t0Mxj-0006FG-9o for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:23 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxc-0000vO-EZ for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:18 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a9a0ef5179dso167698766b.1 for ; Mon, 14 Oct 2024 08:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919573; x=1729524373; 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=BlAXfwq0bKM7PW6MaK14P+kt2FWZdsv7CRfyariz+zKePLKPCyLf/R60ie8u1w2woQ aj2WQUxgew0mLVMb1cypbhfFkJEVM1kCFFAT8Y5Fk/sO4EPtN+8zy3qvyDNEpm7Qtq2+ fP7COyZxzOzpsk/gBYexpXufktnueRY15e2zzjigsoox9SI+T3qa/OpYpY4Gd0ycgoEh VlPDgELZg4zGUfasGNjRggTzVV6Vf2HhITMM/4SKxrjYbsm5B3bjcXFhuYEKa6Pt9lPT ny5YajJjVaFc/6QoeUcLmHA8QNvj7vdYZuA2FcZf1qdDfnz0kcqgyrWifdICcewhwTuE /dVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919573; x=1729524373; 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=VcxSzraylr0TJxCvuCSnIhGtoGghs7Bc1v1Jf7n0lj6yqOwb9LI2zH9tgiLl2ixLoS cAl3EiimgNGSUq3UbuMIbYy33Aq61HCaETFsNbJMhqsmxOIkXLHAKsMqsKQXl4SI+mVk crBaynmgZel4y01j47TQqDOfNYOZBHiX29BDZW+VIaSkgDwJGlYat10xsNPie4ZzAASb a1bKR4WiM2moV11ku2fwntl8/d+YVBulFv2ZU1v2kjgX7CLBZbtcQTDAc1mhc8DnD71l 4UZ4z3glXZ5YEeVlLyyc4+I6JB2GXuL4ykqm51u6Yd2LgchKk5eNUGixFbycRF2eG4CV 9tgw== X-Forwarded-Encrypted: i=1; AJvYcCUb6UWwXq+oEEHMwH9ukygdnVqPqjQja1UqQb/5SnKqaJT1rXX9j7RGledThB/5/lDGiPfai43wUqh0@nongnu.org X-Gm-Message-State: AOJu0YyQUfR/BoPRsQlXMCZAG+Dqyv7NI8wWw9eKlEMr0y0d2Htqn140 VwJixzrcx8asUUydHjC9Qk3YmNabyLDSqsfWiBUzdd5E4qelTI54yHsLcA== X-Google-Smtp-Source: AGHT+IH6xZspJLTMXg0JJ2OXjDRqc9eNq2O9vblLh71wlHqNiGq6yzsrHvnmljocaRvPwFhONjvX2w== X-Received: by 2002:a17:907:7206:b0:a99:509b:f524 with SMTP id a640c23a62f3a-a99b95af331mr1159730266b.57.1728919572908; Mon, 14 Oct 2024 08:26:12 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:12 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 4/8] chardev/mux: convert size members to unsigned int Date: Mon, 14 Oct 2024 17:24:04 +0200 Message-Id: <20241014152408.427700-5-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é Lureau" Cc: qemu-devel@nongnu.org --- 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) bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp) { - int tag = 0; + unsigned int tag = 0; 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) } } -static void mux_chr_send_event(MuxChardev *d, int mux_nr, QEMUChrEvent event) +static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr, + QEMUChrEvent event) { CharBackend *be = d->backends[mux_nr]; @@ -242,7 +243,7 @@ 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 = MUX_CHARDEV(chr); - int i; + unsigned int i; if (!muxes_opened) { return; @@ -275,7 +276,7 @@ static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond) static void char_mux_finalize(Object *obj) { MuxChardev *d = MUX_CHARDEV(obj); - int i; + unsigned int i; for (i = 0; i < d->mux_cnt; i++) { CharBackend *be = d->backends[i]; @@ -300,11 +301,10 @@ static void mux_chr_update_read_handlers(Chardev *chr) chr->gcontext, true, false); } -void mux_set_focus(Chardev *chr, int focus) +void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d = MUX_CHARDEV(chr); - assert(focus >= 0); assert(focus < d->mux_cnt); if (d->focus != -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; /* 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) -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); 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; }; From patchwork Mon Oct 14 15:24:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80434D18129 for ; Mon, 14 Oct 2024 15:27:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxl-0006GT-Jp; Mon, 14 Oct 2024 11:26:25 -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 1t0Mxj-0006FH-9b for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:23 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxc-0000vP-Eg for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:20 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a99f3a5a44cso230216566b.3 for ; Mon, 14 Oct 2024 08:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919574; x=1729524374; 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=BLjua+tOeIv7E0RaGwObuGqs4j05WF+hm8pmAjwxhpmDlXDNHOZJ5vCya3/qH8yPHS kYSyKAwAS6kCGlMWNdCWO6NoP07V+3Axl2M3vQ6nGrCeAUpRb3u9cHrOQTWD1cXn0Scq nnwe4KHHPEgbgtSd1UNy2I7hwdTh/4U5wXbZ6suNn1KBE/6i9WQjJe4+IDcFOepCe0WT acaFQf7JblpMgxoyFlbCoEuaATjQOHe7iYFm27ajEUlD3I3H8aul4Dz+jFjvQIBdS2ja 4WIZS5V/vL5hstGyfN/yOGM+/Bbv1HPLcKr7afmMurSaSgyvlt3bKw3u95PMkfRX3RHf wU5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919574; x=1729524374; 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=WelJGTGhkxZILD9YzFHPdzR+mNIdQ9weQoCkZYkD15+IHf5i3GHSjfT7wHB/zWifNw pqUaWztEDbXEtbyYjkQZyWT2skYwZwO6aEbc+vXBzJjtWDpgKxF9vvo3cdxVLYnbW85+ r0kbuJxoqEkgIqDOHm/T4t9mQko500wsnGDFSG/p0iL+BINNH7Woyo4JDooFtw5QBaqt dIOmZclmdCpAx7YG5yzerFbCHodYOAcnLS8p10TjfjAENAtqc8Rd2KlM8oXoUW+GOZHM kORnsMFrp8rvuF+6A6x74n8+/WU9H+sUQFfpnGWaMennwRfaaq/1OKSyhax8NA4sZ+WW 3B7g== X-Forwarded-Encrypted: i=1; AJvYcCWs0X5lypZOaavbsCYaVSNs04iT3r8d7jJtaYtpEl/9O8qcnmEzMpJyskzQe6yjuMddX9UC0gzf5NEc@nongnu.org X-Gm-Message-State: AOJu0YwxikNop3+mCQ2LPzCye+pk11hF+MY0qj4mPABfENVltdTd4PZT +2UV4yNEOLteOk75gQoF6B4b988hKf82O2zqVsQUvb7vdxzJISWE X-Google-Smtp-Source: AGHT+IEjynpc7uLVbU+yD65ufXEqkRz1AyV7qgrSVykOCB69OQxFw23zt3nWmRr/RKVZYsCHirtodg== X-Received: by 2002:a17:907:7296:b0:a99:e4a2:1cda with SMTP id a640c23a62f3a-a99e4a21d75mr803489266b.56.1728919573710; Mon, 14 Oct 2024 08:26:13 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:13 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 5/8] chardev/mux: introduce `mux_chr_attach_frontend() call Date: Mon, 14 Oct 2024 17:24:05 +0200 Message-Id: <20241014152408.427700-6-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é Lureau" Cc: qemu-devel@nongnu.org --- 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, Error **errp) if (CHARDEV_IS_MUX(s)) { MuxChardev *d = MUX_CHARDEV(s); - if (d->mux_cnt >= 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] = b; - tag = 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); } +bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, + unsigned int *tag, Error **errp) +{ + if (d->mux_cnt >= 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] = b; + *tag = d->mux_cnt++; + + return true; +} + void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d = 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) +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); From patchwork Mon Oct 14 15:24:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93BC0D1812C for ; Mon, 14 Oct 2024 15:27:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxm-0006GV-3a; Mon, 14 Oct 2024 11:26:26 -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 1t0Mxj-0006FI-9z for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:23 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxc-0000vU-ES for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:21 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a99f1fd20c4so326510766b.0 for ; Mon, 14 Oct 2024 08:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919574; x=1729524374; 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=eRudZtM65n9Q3xSB5GQjmkHRO8QI3REi2QYBTmiVgw4=; b=KSUbO8v3nc74scWTg4mB6tVJl34Icp6eAPy+QmCN+3uy22L31JHBsDF1gqVToe+S5R 59V+s/b/Bb76cPwjHKGmFqFYtiQxkgxV7zCQ/1/W4GUpveS5Hau2upYNaAcpLO2duF6p 8cHksARnEbfQRgQfkDyyiqGbuaew4r9GSVxhoekxKK48E6oxcIvOuNwZI5CAJbwo7OEl jamjBHjFZFaV6Snm7uFn87/mX/gNZB6O+ZGwt7fbLWSpoom+5qfBSkzCWSq72bSOZAIr R3NteBGtPZWesVhuS+l3SnFqDGWLHnaWYupOZKtYAqD8CoFTiRgqfOv5OejKRrM2xW4j nzLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919574; x=1729524374; 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=eRudZtM65n9Q3xSB5GQjmkHRO8QI3REi2QYBTmiVgw4=; b=NzaK15buHVDw9MH2y8F0kejA7iGCR5LKO8Q7aEL6bXNSpMvjGWpD8zhV7+xzzP1k3m Pw5Sao9CIGb7A0w1QUCMGJ5gFoGnE3JWioBnllfyJAySQtl9PTnoGUOTlB90grzfaBJv OaaG9sW8AtXgbry1E5aQTzwMH3GwZrrJIs6/Xr+ux6DUvZkvb2mUYqbs4Uc8wzylBtpk kkATXV9/60hGEe5eqM279NxiWhuyypgfe4FQveoZ1lgUKJ4o6Hta7UwZwAA9SusSiAz2 i6HuyVoaQG6zP7e7Sly+QgiFYlw0j4HSbfA0bmf22REYDHEJ6Ff1flCzYPslpK/pixeb 6UKw== X-Forwarded-Encrypted: i=1; AJvYcCV8sOBSkSEZFUEQdhDCfhcPdFdqew+Elus6HNJ2qGZr/eB8S/FkQetUkrsNQwLcKoPsNUkYGpzYuSSh@nongnu.org X-Gm-Message-State: AOJu0YxPeR8H6MEJjiaU6W4y1uPCJ9qiW6MbP81jBb6V80ql+77fLGpX A+akJbihb5MAyyTdKJHmi9dICx4pfg1DU+sfAK6S3LoK/gqHpLSr X-Google-Smtp-Source: AGHT+IFiCnW5NBdsRDYG+ygBTrePXk5jI7swRBMLRf4x2y55kyPMsoZlf+Nf2szW+HQWi3j0+gtIjg== X-Received: by 2002:a17:907:6e89:b0:a9a:a5c:e23b with SMTP id a640c23a62f3a-a9a0a5ce2d0mr379024966b.58.1728919574278; Mon, 14 Oct 2024 08:26:14 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:14 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 6/8] chardev/mux: switch mux frontends management to bitset Date: Mon, 14 Oct 2024 17:24:06 +0200 Message-Id: <20241014152408.427700-7-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x633.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é Lureau" Cc: qemu-devel@nongnu.org --- chardev/char-mux.c | 42 +++++++++++++++++++++++++------------- chardev/char.c | 2 +- chardev/chardev-internal.h | 2 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 9294f955462e..4fc619b2da70 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 != 0); /* Switch to the next registered device */ - mux_set_focus(chr, (d->focus + 1) % d->mux_cnt); + bit = find_next_bit(&d->mux_bitset, MAX_MUX, d->focus + 1); + if (bit >= MAX_MUX) { + bit = find_next_bit(&d->mux_bitset, MAX_MUX, 0); + } + mux_set_focus(chr, bit); break; - case 't': + } case 't': d->timestamps = !d->timestamps; d->timestamps_start = -1; d->linestart = false; @@ -243,15 +251,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 = MUX_CHARDEV(chr); - unsigned int i; + int bit; if (!muxes_opened) { return; } /* Send the event to all registered listeners */ - for (i = 0; i < d->mux_cnt; i++) { - mux_chr_send_event(d, i, event); + bit = -1; + while ((bit = find_next_bit(&d->mux_bitset, MAX_MUX, bit + 1)) < MAX_MUX) { + mux_chr_send_event(d, bit, event); } } @@ -276,10 +285,11 @@ static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond) static void char_mux_finalize(Object *obj) { MuxChardev *d = MUX_CHARDEV(obj); - unsigned int i; + int bit; - for (i = 0; i < d->mux_cnt; i++) { - CharBackend *be = d->backends[i]; + 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; } @@ -304,7 +314,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 >= MAX_MUX) { + unsigned int bit; + + bit = find_next_zero_bit(&d->mux_bitset, MAX_MUX, 0); + if (bit >= MAX_MUX) { error_setg(errp, "too many uses of multiplexed chardev '%s'" " (maximum is " stringify(MAX_MUX) ")", @@ -312,8 +325,9 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, return false; } - d->backends[d->mux_cnt] = b; - *tag = d->mux_cnt++; + d->mux_bitset |= (1 << bit); + d->backends[bit] = b; + *tag = bit; return true; } @@ -322,7 +336,7 @@ void mux_set_focus(Chardev *chr, unsigned int focus) { MuxChardev *d = MUX_CHARDEV(chr); - assert(focus < d->mux_cnt); + assert(find_next_bit(&d->mux_bitset, MAX_MUX, focus) == focus); if (d->focus != -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 = MUX_CHARDEV(s); - return d->mux_cnt > 0; + return d->mux_bitset != 0; } else { return s->be != 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 From patchwork Mon Oct 14 15:24:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0275D18128 for ; Mon, 14 Oct 2024 15:27:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxm-0006GZ-GZ; Mon, 14 Oct 2024 11:26:26 -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 1t0Mxk-0006Fp-J8 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:24 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxf-0000vp-Jr for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:24 -0400 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a9a0474e70eso228740666b.0 for ; Mon, 14 Oct 2024 08:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919576; x=1729524376; 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=m0qoIF6I3bv6HEho2ivi87bpY1Wjjl4fkovu0hrF0fg=; b=HTMYpNM9VX8iYyYV16BS5EQTWBBerbq2g4Fs/hJ4s8vTI87PCQqGQ3B6Q40NMywzTu 68NQzpwg2nbHKRo1AK1+PDSeIZDCqzmnFRSK//y5GO+uBNdT3bRKp7nymjT4kULRYzlq gkcc2IDKoJ5QnGqZAMjgkV+sETjry/s599DTl/ckbtO73MK9ZdpMNOlxtF0FfIS3AlQF jed2FhfJrJzSi7demqaejWGGY94+TckveDgwsW4wTpnRi/957PIQ668bXizyili2NfX9 Bux6GuCjbQyVQRKim7Szz9Ge13VQ75z993MmYeFpgUlRENQ/hXOEaOA2iKEO08ZMwNIN f6XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919576; x=1729524376; 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=m0qoIF6I3bv6HEho2ivi87bpY1Wjjl4fkovu0hrF0fg=; b=stDCGrAajCD6qAGo/KWyPGzb5CWAZgC9c758W8cNOw333T5xJ/8pBsoAFXK/p16Cbv t53qEw+K8twXLe5zXBY/uMeK1NHbD248IM/3VqUAfOV/aYtcjNBZ1fEr65HwG+LY2ItR DxGsFv1KbzJzvs+mNhxBZpFNPqMl3XyOHu1Vyf85ZTeC6i/9oBq4KgYO+Yj1xuOLUM6c 1DHMiQhfVgOBvK2ztKpBqFl2DBTIX29pdC7OUJR5qVR7tuZLVS2h7/kfZNhnzukOr8GH XWZarxruS/BFRK/Fzpi/ACAY+CUq9bq/Ovs1u7J0JDlJmWw/w3x3uO0RIt/O7Uk/tXz9 9kxg== X-Forwarded-Encrypted: i=1; AJvYcCXpSyux8duoO25YJcDjUIc7Denu81TjQvkcfVIB5ngd2KSikaknNA3ccDpsz7m7/Pgz4vSACs6VDhbe@nongnu.org X-Gm-Message-State: AOJu0YwtZOufcSh5E4ZSTbAusW+wLN0YfS/ZZHYMwQzz6+I+2/0/4K9W wnhIJ2A/DchQ9yupbcL/kXtQWwg+J6Ag9iGeXnNgp3NV9vRvcCp7 X-Google-Smtp-Source: AGHT+IHRJPO3UFktVyYkgg4UwsOVSmTlut+kzzXkzyFc/HuRIj28ILC+mV/zriTmyD1QbW7t1nCMdg== X-Received: by 2002:a17:907:3f1f:b0:a99:a9b6:2eb6 with SMTP id a640c23a62f3a-a99e343b0e8mr922420366b.0.1728919575672; Mon, 14 Oct 2024 08:26:15 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:14 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 7/8] chardev/mux: implement detach of frontends from mux Date: Mon, 14 Oct 2024 17:24:07 +0200 Message-Id: <20241014152408.427700-8-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=r.peniaev@gmail.com; helo=mail-ej1-x62c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org With bitset management now it becomes feasible to implement the logic of detaching frontends from multiplexer. Signed-off-by: Roman Penyaev Cc: "Marc-André Lureau" Cc: qemu-devel@nongnu.org --- chardev/char-fe.c | 2 +- chardev/char-mux.c | 21 ++++++++++++++++++--- chardev/chardev-internal.h | 1 + 3 files changed, 20 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 = MUX_CHARDEV(b->chr); - d->backends[b->tag] = NULL; + mux_chr_detach_frontend(d, b->tag); } if (del) { Object *obj = OBJECT(b->chr); diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 4fc619b2da70..bda5c45e6058 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); 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, 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); From patchwork Mon Oct 14 15:24:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Penyaev X-Patchwork-Id: 13835238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA485D18128 for ; Mon, 14 Oct 2024 15:27:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Mxq-0006IR-3k; Mon, 14 Oct 2024 11:26:30 -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 1t0Mxk-0006Fo-Hs for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:24 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Mxh-0000vw-KA for qemu-devel@nongnu.org; Mon, 14 Oct 2024 11:26:24 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-539e1543ab8so4276404e87.2 for ; Mon, 14 Oct 2024 08:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728919577; x=1729524377; 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=ao+ZrR8KweE/5YbZQbnoQf1z48TBhH4vSKIWLCN6KCMnFrs1xtukgKz7At4/ieItVj vxaQhKiT9tRjNsusHGzXBZviOyejBrTJFyzEYVtq9eiT1B27nGioBhNFY4KjK/FWBmgD 15iwt8NPEvjNcwiI6OR81TQzNx+O7qIh6mASae4zIqitDWQnhNPcvhoBM7zIbvFjfsik Cl5xS9n8C8vi9IGij3Q6iAdDas+TBwIMTCiH3bmVsrLVHphAAtzso+p3GM9DxBhC4oHi rPo9Cd07r/KUQjDmTpoNGeuSUfTgQWjQraRXphmGt0xPC3PX8aEoNNbXE618W1/RlIiS WAAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919577; x=1729524377; 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=QjcPXa0ezVzefnmyaX90ibZbPcfPMAxVXe4ifB1LwbSHDyhXL9sYYGkZ3IVGE+cXGX bmn3m09zDIZv6DZYN8NpepeWhzh8079CNp5NgNFv4La6LHRk/audN6oU6z7sGcxiEBR3 wOO0WKJTwXNliVSfWF7tw+mjkNkDnvkSswXf8cVYP3Akv+9tUv/le4XSFLUIzTwmdkVA piAI5A3D1P1BKJOFA52SxwQLw3hmGWkWZv9PfZSEWqzAZLjQ2AdX0sm2gRiQCHz5oyBO 0V1tpkVh9joCJN6a14asUbEXnxj9XvnH/im80uM/3j2RnMYupiUKXe6amaFwdu/w17sA vqOA== X-Forwarded-Encrypted: i=1; AJvYcCWftznYq7lLY084GEx5WTWVrMDFNzzAxhuOyjCQT75i5QILRQIQ3la8Tb99QdI0UdRDaNt66oTGt2am@nongnu.org X-Gm-Message-State: AOJu0YwkTXLiWr23Nv+EyzCPG461msNduDabfIsyKXbYbDz6OIX/84K2 gve58MDWlIfohfn6ii3P5pslTyj7hadpW95EvgInPuG9I3SQKnsW9w2m4Q== X-Google-Smtp-Source: AGHT+IHCOPZH9o0oJOAmtTOxYL3dSlzfMHZ27dFbAyKyjaSYxeLcfQa2M04Ak1OI8w4o5mtHu/0adA== X-Received: by 2002:a05:6512:3ba5:b0:52e:936e:a237 with SMTP id 2adb3069b0e04-539e54e74f6mr4398904e87.16.1728919576245; Mon, 14 Oct 2024 08:26:16 -0700 (PDT) Received: from finn.fritz.box ([2a02:8109:8384:1400:eb7f:8fd0:f96c:766b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a13396603sm133689966b.169.2024.10.14.08.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:26:15 -0700 (PDT) From: Roman Penyaev To: Cc: Roman Penyaev , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH v2 8/8] tests/unit/test-char: implement a few mux remove test cases Date: Mon, 14 Oct 2024 17:24:08 +0200 Message-Id: <20241014152408.427700-9-r.peniaev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com> References: <20241014152408.427700-1-r.peniaev@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=r.peniaev@gmail.com; helo=mail-lf1-x132.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é Lureau" Cc: qemu-devel@nongnu.org --- 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 +#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 = { 0, false, 0, false, }, h2 = { 0, false, 0, false, }; CharBackend chr_be1, chr_be2; + Error *error = NULL; + + /* Create mux and chardev to be immediately removed */ + opts = 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 = 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); opts = 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); qemu_chr_fe_deinit(&chr_be1, false); - qemu_chr_fe_deinit(&chr_be2, true); + + error = NULL; + qmp_chardev_remove("mux-label", &error); + g_assert_cmpstr(error_get_pretty(error), ==, "Chardev 'mux-label' is busy"); + + qemu_chr_fe_deinit(&chr_be2, false); + qmp_chardev_remove("mux-label", &error_abort); }