From nobody Tue Nov 4 05:26:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505975850399693.390921263274; Wed, 20 Sep 2017 23:37:30 -0700 (PDT) Received: from localhost ([::1]:52058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv73-0007QK-N1 for importer@patchew.org; Thu, 21 Sep 2017 02:37:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv5q-0006gg-T7 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duv5q-0001Da-2R for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duv5p-0001DE-Px for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C82A1C0587C5 for ; Thu, 21 Sep 2017 06:36:12 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99187600CA; Thu, 21 Sep 2017 06:36:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C82A1C0587C5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 14:35:51 +0800 Message-Id: <1505975754-21555-2-git-send-email-peterx@redhat.com> In-Reply-To: <1505975754-21555-1-git-send-email-peterx@redhat.com> References: <1505975754-21555-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Sep 2017 06:36:12 +0000 (UTC) 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/4] chardev: new qemu_chr_be_update_read_handlers() 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: Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a wrapper for the chr_update_read_handler(). Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fe.c | 7 ++----- chardev/char.c | 10 ++++++++++ include/chardev/char.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f3af6ae..ee6d596 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -253,7 +253,6 @@ void qemu_chr_fe_set_handlers(CharBackend *b, bool set_open) { Chardev *s; - ChardevClass *cc; int fe_open; =20 s =3D b->chr; @@ -261,7 +260,6 @@ void qemu_chr_fe_set_handlers(CharBackend *b, return; } =20 - cc =3D CHARDEV_GET_CLASS(s); if (!opaque && !fd_can_read && !fd_read && !fd_event) { fe_open =3D 0; remove_fd_in_watch(s); @@ -273,9 +271,8 @@ void qemu_chr_fe_set_handlers(CharBackend *b, b->chr_event =3D fd_event; b->chr_be_change =3D be_change; b->opaque =3D opaque; - if (cc->chr_update_read_handler) { - cc->chr_update_read_handler(s, context); - } + + qemu_chr_be_update_read_handlers(s, context); =20 if (set_open) { qemu_chr_fe_set_open(b, fe_open); diff --git a/chardev/char.c b/chardev/char.c index b6fd5eb..e090dd5 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -180,6 +180,16 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int l= en) } } =20 +void qemu_chr_be_update_read_handlers(Chardev *s, + GMainContext *context) +{ + ChardevClass *cc =3D CHARDEV_GET_CLASS(s); + + if (cc->chr_update_read_handler) { + cc->chr_update_read_handler(s, context); + } +} + int qemu_chr_add_client(Chardev *s, int fd) { return CHARDEV_GET_CLASS(s)->chr_add_client ? diff --git a/include/chardev/char.h b/include/chardev/char.h index 66dde46..2068ea4 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -169,6 +169,16 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int l= en); void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len); =20 /** + * @qemu_chr_be_update_read_handlers: + * + * Invoked when frontend read handlers are setup + * + * @context the gcontext that will be used to attach the watch sources + */ +void qemu_chr_be_update_read_handlers(Chardev *s, + GMainContext *context); + +/** * @qemu_chr_be_event: * * Send an event from the back end to the front end. --=20 2.7.4 From nobody Tue Nov 4 05:26:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505975952572541.3116990363084; Wed, 20 Sep 2017 23:39:12 -0700 (PDT) Received: from localhost ([::1]:52062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv8h-00008H-Qt for importer@patchew.org; Thu, 21 Sep 2017 02:39:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv5t-0006ia-RZ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duv5t-0001Eu-13 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51808) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duv5s-0001ET-RU for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA785C0587C1 for ; Thu, 21 Sep 2017 06:36:15 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FE9D600CA; Thu, 21 Sep 2017 06:36:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA785C0587C1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 14:35:52 +0800 Message-Id: <1505975754-21555-3-git-send-email-peterx@redhat.com> In-Reply-To: <1505975754-21555-1-git-send-email-peterx@redhat.com> References: <1505975754-21555-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Sep 2017 06:36:16 +0000 (UTC) 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 2/4] chardev: add Chardev.gcontext field 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: Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It caches the gcontext that is used to poll the chardev IO. Before this patch, we only passed it in via chr_update_read_handlers(). However that may not be enough if the char backend is disconnected and reconnected afterward. There are chardev codes that still assumed the context be NULL (which is the main context). Will fix that up in following up patches. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char.c | 1 + include/chardev/char.h | 1 + 2 files changed, 2 insertions(+) diff --git a/chardev/char.c b/chardev/char.c index e090dd5..89eabea 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -185,6 +185,7 @@ void qemu_chr_be_update_read_handlers(Chardev *s, { ChardevClass *cc =3D CHARDEV_GET_CLASS(s); =20 + s->gcontext =3D context; if (cc->chr_update_read_handler) { cc->chr_update_read_handler(s, context); } diff --git a/include/chardev/char.h b/include/chardev/char.h index 2068ea4..84fb773 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -55,6 +55,7 @@ struct Chardev { int logfd; int be_open; GSource *gsource; + GMainContext *gcontext; DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); }; =20 --=20 2.7.4 From nobody Tue Nov 4 05:26:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505975950240605.5970863108263; Wed, 20 Sep 2017 23:39:10 -0700 (PDT) Received: from localhost ([::1]:52061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv8f-00005z-CI for importer@patchew.org; Thu, 21 Sep 2017 02:39:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv5z-0006o8-IT for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duv5w-0001GZ-DL for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duv5w-0001G4-5s for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AEAA12987B for ; Thu, 21 Sep 2017 06:36:19 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77ACF600CA; Thu, 21 Sep 2017 06:36:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2AEAA12987B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 14:35:53 +0800 Message-Id: <1505975754-21555-4-git-send-email-peterx@redhat.com> In-Reply-To: <1505975754-21555-1-git-send-email-peterx@redhat.com> References: <1505975754-21555-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Sep 2017 06:36:19 +0000 (UTC) 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 3/4] chardev: use per-dev context for io_add_watch_poll 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: Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It was only passed in by chr_update_read_handlers(). However when reconnect, we'll lose that context information. So if a chardev was running on another context (rather than the default context, the NULL pointer), it'll switch back to the default context if reconnection happens. But, it should really stick to the old context. Convert all the callers of io_add_watch_poll() to use the internally cached gcontext. Then the context should be able to survive even after reconnections. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fd.c | 2 +- chardev/char-pty.c | 2 +- chardev/char-socket.c | 4 ++-- chardev/char-udp.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 6a62a54..09fbb07 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -94,7 +94,7 @@ static void fd_chr_update_read_handler(Chardev *chr, chr->gsource =3D io_add_watch_poll(chr, s->ioc_in, fd_chr_read_poll, fd_chr_read, chr, - context); + chr->gcontext); } } =20 diff --git a/chardev/char-pty.c b/chardev/char-pty.c index e5d20a0..d239c04 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -219,7 +219,7 @@ static void pty_chr_state(Chardev *chr, int connected) chr->gsource =3D io_add_watch_poll(chr, s->ioc, pty_chr_read_poll, pty_chr_read, - chr, NULL); + chr, chr->gcontext); } } } diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 1ae730a..ee71cbe 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -516,7 +516,7 @@ static void tcp_chr_connect(void *opaque) chr->gsource =3D io_add_watch_poll(chr, s->ioc, tcp_chr_read_poll, tcp_chr_read, - chr, NULL); + chr, chr->gcontext); } qemu_chr_be_event(chr, CHR_EVENT_OPENED); } @@ -535,7 +535,7 @@ static void tcp_chr_update_read_handler(Chardev *chr, chr->gsource =3D io_add_watch_poll(chr, s->ioc, tcp_chr_read_poll, tcp_chr_read, chr, - context); + chr->gcontext); } } =20 diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 4ee11d3..106dee1 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -110,7 +110,7 @@ static void udp_chr_update_read_handler(Chardev *chr, chr->gsource =3D io_add_watch_poll(chr, s->ioc, udp_chr_read_poll, udp_chr_read, chr, - context); + chr->gcontext); } } =20 --=20 2.7.4 From nobody Tue Nov 4 05:26:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505976032394819.6511084703321; Wed, 20 Sep 2017 23:40:32 -0700 (PDT) Received: from localhost ([::1]:52070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv9z-00014a-Fl for importer@patchew.org; Thu, 21 Sep 2017 02:40:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duv62-0006q7-MR for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duv61-0001J9-KR for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duv61-0001Io-CX for qemu-devel@nongnu.org; Thu, 21 Sep 2017 02:36:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77F9087649 for ; Thu, 21 Sep 2017 06:36:24 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98EBF600CA; Thu, 21 Sep 2017 06:36:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77F9087649 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 14:35:54 +0800 Message-Id: <1505975754-21555-5-git-send-email-peterx@redhat.com> In-Reply-To: <1505975754-21555-1-git-send-email-peterx@redhat.com> References: <1505975754-21555-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Sep 2017 06:36:24 +0000 (UTC) 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 4/4] chardev: remove context in chr_update_read_handler 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: Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We had a per-chardev cache for context, then we don't need this parameter to be passed in every time when chr_update_read_handler() called. As long as we are calling chr_update_read_handler() using qemu_chr_be_update_read_handlers() we'll be fine. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fd.c | 3 +-- chardev/char-pty.c | 3 +-- chardev/char-socket.c | 3 +-- chardev/char-udp.c | 3 +-- chardev/char.c | 2 +- include/chardev/char.h | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 09fbb07..2c9b2ce 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -84,8 +84,7 @@ static GSource *fd_chr_add_watch(Chardev *chr, GIOConditi= on cond) return qio_channel_create_watch(s->ioc_out, cond); } =20 -static void fd_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void fd_chr_update_read_handler(Chardev *chr) { FDChardev *s =3D FD_CHARDEV(chr); =20 diff --git a/chardev/char-pty.c b/chardev/char-pty.c index d239c04..761ae6d 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -112,8 +112,7 @@ static void pty_chr_update_read_handler_locked(Chardev = *chr) } } =20 -static void pty_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void pty_chr_update_read_handler(Chardev *chr) { qemu_mutex_lock(&chr->chr_write_lock); pty_chr_update_read_handler_locked(chr); diff --git a/chardev/char-socket.c b/chardev/char-socket.c index ee71cbe..e65148f 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -521,8 +521,7 @@ static void tcp_chr_connect(void *opaque) qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 -static void tcp_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void tcp_chr_update_read_handler(Chardev *chr) { SocketChardev *s =3D SOCKET_CHARDEV(chr); =20 diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 106dee1..d46ff7a 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -100,8 +100,7 @@ static gboolean udp_chr_read(QIOChannel *chan, GIOCondi= tion cond, void *opaque) return TRUE; } =20 -static void udp_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void udp_chr_update_read_handler(Chardev *chr) { UdpChardev *s =3D UDP_CHARDEV(chr); =20 diff --git a/chardev/char.c b/chardev/char.c index 89eabea..2ae4f46 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -187,7 +187,7 @@ void qemu_chr_be_update_read_handlers(Chardev *s, =20 s->gcontext =3D context; if (cc->chr_update_read_handler) { - cc->chr_update_read_handler(s, context); + cc->chr_update_read_handler(s); } } =20 diff --git a/include/chardev/char.h b/include/chardev/char.h index 84fb773..43aabcc 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -238,7 +238,7 @@ typedef struct ChardevClass { int (*chr_write)(Chardev *s, const uint8_t *buf, int len); int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len); GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond); - void (*chr_update_read_handler)(Chardev *s, GMainContext *context); + void (*chr_update_read_handler)(Chardev *s); int (*chr_ioctl)(Chardev *s, int cmd, void *arg); int (*get_msgfds)(Chardev *s, int* fds, int num); int (*set_msgfds)(Chardev *s, int *fds, int num); --=20 2.7.4