From patchwork Tue Feb 22 10:18:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 83954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F107BB70CB for ; Tue, 22 Feb 2011 21:33:09 +1100 (EST) Received: from localhost ([127.0.0.1]:58249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrpYJ-0000FQ-A8 for incoming@patchwork.ozlabs.org; Tue, 22 Feb 2011 05:33:07 -0500 Received: from [140.186.70.92] (port=39578 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrpLs-00012e-8G for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:20:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrpLq-0005qy-VS for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:20:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrpLq-0005qt-Lo for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:20:14 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1MAKCnx030343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Feb 2011 05:20:12 -0500 Received: from localhost (ovpn-113-98.phx2.redhat.com [10.3.113.98]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1MAJwWb003046; Tue, 22 Feb 2011 05:20:06 -0500 From: Amit Shah To: qemu list Date: Tue, 22 Feb 2011 15:48:36 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Amit Shah , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 7/7] char: pty: Use new iohandler api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Update the pty code to use the new iohandler api. The change is mostly mechanical with a new iohandler function calling the older functions depending on the value of the 'mask' field. Signed-off-by: Amit Shah --- qemu-char.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index ade28ba..6875b00 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -929,12 +929,28 @@ static void pty_chr_read(void *opaque) } } +static int pty_iohandler(void *opaque, unsigned int mask) +{ + int ret; + + ret = 0; + switch(mask) { + case IOH_MASK_CAN_READ: + ret = pty_chr_read_poll(opaque); + break; + case IOH_MASK_READ: + pty_chr_read(opaque); + break; + } + return ret; +} + static void pty_chr_update_read_handler(CharDriverState *chr) { PtyCharDriver *s = chr->opaque; - qemu_set_fd_handler2(s->fd, pty_chr_read_poll, - pty_chr_read, NULL, chr); + assign_iohandler(s->fd, pty_iohandler, IOH_MASK_CAN_READ|IOH_MASK_READ, + chr); s->polling = 1; /* * Short timeout here: just need wait long enougth that qemu makes @@ -952,7 +968,7 @@ static void pty_chr_state(CharDriverState *chr, int connected) PtyCharDriver *s = chr->opaque; if (!connected) { - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + remove_iohandler(s->fd); s->connected = 0; s->polling = 0; /* (re-)connect poll interval for idle guests: once per second. @@ -988,7 +1004,7 @@ static void pty_chr_close(struct CharDriverState *chr) { PtyCharDriver *s = chr->opaque; - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + remove_iohandler(s->fd); close(s->fd); qemu_del_timer(s->timer); qemu_free_timer(s->timer);