From nobody Sun Nov 2 00:18:15 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509723019593247.70725913508886; Fri, 3 Nov 2017 08:30:19 -0700 (PDT) Received: from localhost ([::1]:37177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAdv6-0005My-4U for importer@patchew.org; Fri, 03 Nov 2017 11:30:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAdte-0004Xq-Oq for qemu-devel@nongnu.org; Fri, 03 Nov 2017 11:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAdtd-0005aj-Ok for qemu-devel@nongnu.org; Fri, 03 Nov 2017 11:28:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eAdtd-0005ZQ-Gd for qemu-devel@nongnu.org; Fri, 03 Nov 2017 11:28:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B95E7266D; Fri, 3 Nov 2017 15:28:36 +0000 (UTC) Received: from localhost (ovpn-112-63.ams2.redhat.com [10.36.112.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A16260BE5; Fri, 3 Nov 2017 15:28:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9B95E7266D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 3 Nov 2017 16:28:23 +0100 Message-Id: <20171103152824.21948-2-marcandre.lureau@redhat.com> In-Reply-To: <20171103152824.21948-1-marcandre.lureau@redhat.com> References: <20171103152824.21948-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 03 Nov 2017 15:28:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] chardev: fix backend events regression with mux chardev 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: pbonzini@redhat.com, kirill.shutemov@linux.intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Kirill noticied that on recent versions on QEMU he was not able to trigger SysRq to invoke debug capabilites of Linux Kernel. He tracked it down to qemu_chr_be_event() ignoring CHR_EVENT_BREAK due s->be being NULL. The bug was introduced in 2.8, commit a4afa548fc6d ("char: move front end handlers in CharBackend"). Since the commit, the qemu_chr_be_event() failed to deliver CHR_EVENT_BREAK due to qemu_chr_fe_init() does not set s->be in case of mux. Let's fix this by teaching mux to send an event to the frontend with the focus. Reported-by: Kirill A. Shutemov Signed-off-by: Marc-Andr=C3=A9 Lureau Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend") Tested-by: Kirill A. Shutemov --- include/chardev/char.h | 1 + chardev/char-mux.c | 8 ++++++++ chardev/char.c | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/chardev/char.h b/include/chardev/char.h index 43aabccef5..778d610295 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -248,6 +248,7 @@ typedef struct ChardevClass { void (*chr_accept_input)(Chardev *chr); void (*chr_set_echo)(Chardev *chr, bool echo); void (*chr_set_fe_open)(Chardev *chr, int fe_open); + void (*chr_be_event)(Chardev *s, int event); } ChardevClass; =20 Chardev *qemu_chardev_new(const char *id, const char *typename, diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 4cda5e7458..0553b48b90 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -123,6 +123,13 @@ static void mux_chr_send_event(MuxChardev *d, int mux_= nr, int event) } } =20 +static void mux_chr_be_event(Chardev *chr, int event) +{ + MuxChardev *d =3D MUX_CHARDEV(chr); + + mux_chr_send_event(d, d->focus, event); +} + static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch) { if (d->term_got_escape) { @@ -346,6 +353,7 @@ static void char_mux_class_init(ObjectClass *oc, void *= data) cc->chr_write =3D mux_chr_write; cc->chr_accept_input =3D mux_chr_accept_input; cc->chr_add_watch =3D mux_chr_add_watch; + cc->chr_be_event =3D mux_chr_be_event; } =20 static const TypeInfo char_mux_type_info =3D { diff --git a/chardev/char.c b/chardev/char.c index 2ae4f465ec..8c3765ee99 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -43,10 +43,19 @@ static Object *get_chardevs_root(void) return container_get(object_get_root(), "/chardevs"); } =20 -void qemu_chr_be_event(Chardev *s, int event) +static void chr_be_event(Chardev *s, int event) { CharBackend *be =3D s->be; =20 + if (!be || !be->chr_event) { + return; + } + + be->chr_event(be->opaque, event); +} + +void qemu_chr_be_event(Chardev *s, int event) +{ /* Keep track if the char device is open */ switch (event) { case CHR_EVENT_OPENED: @@ -57,11 +66,7 @@ void qemu_chr_be_event(Chardev *s, int event) break; } =20 - if (!be || !be->chr_event) { - return; - } - - be->chr_event(be->opaque, event); + CHARDEV_GET_CLASS(s)->chr_be_event(s, event); } =20 /* Not reporting errors from writing to logfile, as logs are @@ -244,6 +249,7 @@ static void char_class_init(ObjectClass *oc, void *data) ChardevClass *cc =3D CHARDEV_CLASS(oc); =20 cc->chr_write =3D null_chr_write; + cc->chr_be_event =3D chr_be_event; } =20 static void char_finalize(Object *obj) --=20 2.15.0.rc0.40.gaefcc5f6f