From patchwork Mon Nov 5 12:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Artem Pisarenko X-Patchwork-Id: 10668143 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 E342615A6 for ; Mon, 5 Nov 2018 12:47:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D20C0296BE for ; Mon, 5 Nov 2018 12:47:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4ABB296F3; Mon, 5 Nov 2018 12:47:09 +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 77AE9296BE for ; Mon, 5 Nov 2018 12:47:09 +0000 (UTC) Received: from localhost ([::1]:34840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJeHc-0007o3-P0 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Nov 2018 07:47:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJeGD-0006oI-Ky for qemu-devel@nongnu.org; Mon, 05 Nov 2018 07:45:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJeG9-0000st-Kr for qemu-devel@nongnu.org; Mon, 05 Nov 2018 07:45:39 -0500 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:39032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJeG5-0000AO-Ly for qemu-devel@nongnu.org; Mon, 05 Nov 2018 07:45:34 -0500 Received: by mail-lj1-x232.google.com with SMTP id t9-v6so4687029ljh.6 for ; Mon, 05 Nov 2018 04:45:18 -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=3Hf6F0yBnw0vgYFKaIiyIpA9jdMbwli9m1ENaXTqNkk=; b=X8w15gzBMm/RG5w5J+dWH/C4RgMvpXz93hp/XKyHLdfUiShMI1XvkmT6swt67Fftdn E68X62WgvDzMwQ+sxF17AAVdX2nXBp3Hy3mHb9LoidUSgR+N1bW8sijyiKzP7EFKlDTg oMgnkmfHR4JLLOvbHZOj3a0sbCbmczml9xhS9ponCUjqEGBUY5SAGz0fhpCQnLABuNmf DBhrumQpuwiKq8AgtRbhL18nL/IL7JunFVSDXsDRhBp9e9KaDMNqVE06DW5RL1u5gI6U ZRgGzs46D/HXLQ4ZWlnRIcWDqxo4ujeZ4KcxgMd50VCFIhsLKy9Ppc/MD56CpAz9H4ks JMvQ== 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=3Hf6F0yBnw0vgYFKaIiyIpA9jdMbwli9m1ENaXTqNkk=; b=Z1my8o/bZV9Ikwkrn5HzEBBjj85texf86LW4QltgafPnCC136jUhoAfBicZ1yozdGP rvOPst2sziY4pFPyRUOaR/dY/ZZRuRm+XfSAVTGRXmvWMI2s2aarVHuGTq4c5a5Tlpht boVj2PyLx4Ly7xETzY4jeBoQl5EIgmSqz3/q+fS4yqHNxjPYTfsM3KDJIJDW8apDoJMR pFCJbcuJ4Os/c4drwYOfNK8o0lOqMsNHPgB0cpxMoBjjnRcHNrb0CKJns1UP7SvzLvzF v+AxpaqcUGhvV9Fm2l83F06c8acTn78GaENI+1z/HnlL+EL0w/iXBPXS768BFZ3xO0ym fLmg== X-Gm-Message-State: AGRZ1gL0j4dWZZXKhv0B0+5wjNUJKejY9gAQFs5hll1bR+PpaawDmKpn 0/lDabZYXNRKjOW9zdm/9s9s7Dx8 X-Google-Smtp-Source: AJdET5dreMZ26JzkR2g1Ix4R3St+ON3IVv7uYgWa3DfTZiWAouBSEZkQZQNJMRg3k8CUkGA6DD8pQg== X-Received: by 2002:a2e:944d:: with SMTP id o13-v6mr3573873ljh.7.1541421917154; Mon, 05 Nov 2018 04:45:17 -0800 (PST) Received: from localhost.localdomain ([77.221.221.49]) by smtp.gmail.com with ESMTPSA id 4-v6sm3967415ljw.84.2018.11.05.04.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Nov 2018 04:45:16 -0800 (PST) From: Artem Pisarenko To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 18:45:08 +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::232 Subject: [Qemu-devel] [PATCH v2 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. 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(-)