From nobody Tue Nov 4 11:01:34 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 --- 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