From patchwork Tue Nov 6 12:40:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Artem Pisarenko X-Patchwork-Id: 10670283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D14E13BF for ; Tue, 6 Nov 2018 12:48:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D936429281 for ; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA15293F9; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43C4E29290 for ; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) Received: from localhost ([::1]:40756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0mR-0008Mb-DJ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Nov 2018 07:48:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0kq-0004lC-9H for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:46:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK0fL-00012G-67 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:41:14 -0500 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:46188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK0fJ-0000h9-EG for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:41:05 -0500 Received: by mail-lf1-x141.google.com with SMTP id f23so4166409lfc.13 for ; Tue, 06 Nov 2018 04:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Bov3zPzsW+P1v4lazxFqCo4C52TZ/0X+211hTbBJMMI=; b=FxZzHHZy39xnb6JhT0j+J5uoU4mC1FgWesAMJ9FKXAh8b8O3fKBa3La1Q9jAQW3HFi OC7fH+gVfJuKJIxbgmjHEmZNRVIqmjVNJLi8BaNcdG3gtKe88dmleDvXtEWvwRhg9h2R qNDWSARN9cpDpPIs7lxFFawThBokrTiI/pgvEpSFPrj2ZpI7qtX0gSfjcLI0sixwTXfC 8TnZ9VURItfoQPjGWHtSgdwAjYveKIcjWyhSM7lOTriLA7IoDgdBCTppAdLMUrEv/qsX 47VUSxCasKwJJP1iGGlyIVoj0QGiaRR007XQ1WRQfIF4Bf6HjROv6Lp5VNNjCAPq8eOR SZiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Bov3zPzsW+P1v4lazxFqCo4C52TZ/0X+211hTbBJMMI=; b=DaSdlk+/9vEcBQXG2oU74iW6KXBjMjxqcWSe4Z4cR7RTek70Tzb7cMlEMnrothGBH2 DihmgyUYZbXngZP2M/NqUDYslnS/Y1UP9dhes+covHF3WTEVTYvNYmrOh6v1mxduTJLs NxzPdDz+RQdbKGgGurp+scpxNeUy+3WLie9VkCM1F7de72udL2InHc82JaxVrP1ZoWrv hWSYxtgNAzkNrHciwDAkHDHFfBDKVEMQPYuNt2t+4IiEaQP+d1SWtaepHGyo8hp9IpNQ ponqsCcobD3kS93edaI9xGmgrvjUV3Eknwv3f2DKBvwDViwhdJMSSb+w+ZzuYfFcLSOA FKJw== X-Gm-Message-State: AGRZ1gIOvu8VlMW9lRwusHC4SOyk95kIIJGTtyc4wuLQl87MpB5jgFEs YpRxu3rUzFcikyD+QS94m/M5wq7/ X-Google-Smtp-Source: AJdET5eJO92nbNFTjkFAL+YrfH6RTGAIb9zjMVa+r3Kl+NE9FcOiauP007daj1y1IyM9WPWCto8BIw== X-Received: by 2002:a19:9904:: with SMTP id b4mr14640826lfe.95.1541508058378; Tue, 06 Nov 2018 04:40:58 -0800 (PST) Received: from localhost.localdomain ([77.221.221.49]) by smtp.gmail.com with ESMTPSA id r69sm829190lfi.15.2018.11.06.04.40.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Nov 2018 04:40:57 -0800 (PST) From: Artem Pisarenko To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 18:40:50 +0600 Message-Id: X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::141 Subject: [Qemu-devel] [PATCH v3 0/2] chardev: fix mess in OPENED/CLOSED events when muxed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Artem Pisarenko , =?utf-8?q?Marc-Andr=C3=A9_Lu?= =?utf-8?q?reau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This issue actually more complex. Idea of generating events from inside function called '*_set_handlers' isn't good, at least its implicit nature, and especially a fact, that function decides about open state (see 'fe_open' variable), but generates event only in one direction. Combined with 'mux_chr_set_handlers()' hack this makes things even worse. Better solution is to change fe interface and rewrite all frontends code (a lot of stuff in hw/char/* and somewhere else). Although first patch doesn't fix any bug (known to me), its main effect is optimization of emulation performance by avoiding extra activity. Added testing demonstrates issue and prevents potential bugs in future. v3 changes: - extended commit message explaining fix (as supposed by Marc-André Lureau) v2 changes: - fix failed unit test - 'mux_chr_set_handlers()' hack rewritten (as supposed by Marc-André Lureau) - added testing of issue to unit test (new patch) Artem Pisarenko (2): chardev: fix mess in OPENED/CLOSED events when muxed tests/test-char: add muxed chardev testing for open/close chardev/char-fe.c | 33 +++++++++++++------ chardev/char-mux.c | 16 +++++----- include/chardev/char-fe.h | 18 ++++++++++- tests/test-char.c | 80 +++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 127 insertions(+), 20 deletions(-)