From patchwork Tue Mar 9 22:26:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47189 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]) by ozlabs.org (Postfix) with ESMTP id 50185B7D22 for ; Wed, 10 Mar 2010 09:35:11 +1100 (EST) Received: from localhost ([127.0.0.1]:37765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Np7v7-0006IT-Vm for incoming@patchwork.ozlabs.org; Tue, 09 Mar 2010 17:28:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Np7tG-0005om-1g for qemu-devel@nongnu.org; Tue, 09 Mar 2010 17:27:02 -0500 Received: from [199.232.76.173] (port=49489 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Np7tF-0005oF-Bw for qemu-devel@nongnu.org; Tue, 09 Mar 2010 17:27:01 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Np7tD-0008OH-QA for qemu-devel@nongnu.org; Tue, 09 Mar 2010 17:27:01 -0500 Received: from mx20.gnu.org ([199.232.41.8]:11432) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Np7t9-0008Lv-FS for qemu-devel@nongnu.org; Tue, 09 Mar 2010 17:26:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Np7sj-00049d-17 for qemu-devel@nongnu.org; Tue, 09 Mar 2010 17:26:29 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o29MQFBj014615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Mar 2010 17:26:16 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o29MQ3Qe017445; Tue, 9 Mar 2010 17:26:14 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 9 Mar 2010 23:26:01 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 7/9] Introduce qemu_set_fd_poll_handler() 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 Patch consist: s/qemu_set_fd_handler2(fd, poll, read, NULL, o)/ qemu_set_fd_poll_handler(fd, poll, read, o)/ Signed-off-by: Juan Quintela --- qemu-char.c | 18 +++++++++--------- qemu-char.h | 4 ++++ vl.c | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 43d0758..4822209 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -576,8 +576,8 @@ static void fd_chr_update_read_handler(CharDriverState *chr) if (s->fd_in >= 0) { if (display_type == DT_NOGRAPHIC && s->fd_in == 0) { } else { - qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll, - fd_chr_read, NULL, chr); + qemu_set_fd_poll_handler(s->fd_in, fd_chr_read_poll, + fd_chr_read, chr); } } } @@ -757,7 +757,7 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) return NULL; chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; - qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); + qemu_set_fd_poll_handler(0, stdio_read_poll, stdio_read, chr); stdio_nb_clients++; term_init(opts); @@ -885,8 +885,8 @@ 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); + qemu_set_fd_poll_handler(s->fd, pty_chr_read_poll, + pty_chr_read, chr); s->polling = 1; /* * Short timeout here: just need wait long enougth that qemu makes @@ -1831,8 +1831,8 @@ static void udp_chr_update_read_handler(CharDriverState *chr) NetCharDriver *s = chr->opaque; if (s->fd >= 0) { - qemu_set_fd_handler2(s->fd, udp_chr_read_poll, - udp_chr_read, NULL, chr); + qemu_set_fd_poll_handler(s->fd, udp_chr_read_poll, + udp_chr_read, chr); } } @@ -2072,8 +2072,8 @@ static void tcp_chr_connect(void *opaque) TCPCharDriver *s = chr->opaque; s->connected = 1; - qemu_set_fd_handler2(s->fd, tcp_chr_read_poll, - tcp_chr_read, NULL, chr); + qemu_set_fd_poll_handler(s->fd, tcp_chr_read_poll, + tcp_chr_read, chr); qemu_chr_generic_open(chr); } diff --git a/qemu-char.h b/qemu-char.h index 8d7da54..ffc6cb6 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -113,5 +113,9 @@ int qemu_set_fd_read_handler(int fd, int qemu_set_fd_write_handler(int fd, IOHandler *fd_read, void *opaque); +int qemu_set_fd_poll_handler(int fd, + IOCanRWHandler *fd_read_poll, + IOHandler *fd_read, + void *opaque); #endif diff --git a/vl.c b/vl.c index c061732..2cb35dc 100644 --- a/vl.c +++ b/vl.c @@ -2684,6 +2684,22 @@ int qemu_set_fd_write_handler(int fd, return qemu_set_fd_handler2(fd, NULL, NULL, fd_write, opaque); } +int qemu_set_fd_poll_handler(int fd, + IOCanRWHandler *fd_read_poll, + IOHandler *fd_read, + void *opaque) +{ + if(fd_read_poll == NULL) { + fprintf(stderr, "qemu_set_fd_poll_handler: NULL poll handler\n"); + exit(1); + } + if(fd_read == NULL) { + fprintf(stderr, "qemu_set_fd_poll_handler: NULL read handler\n"); + exit(1); + } + return qemu_set_fd_handler2(fd, fd_read_poll, fd_read, NULL, opaque); +} + #ifdef _WIN32 /***********************************************************/ /* Polling handling */