From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39385 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrpLR-0000lO-D1 for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrpLQ-0005mK-6z for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:19:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrpLP-0005m0-Qu for qemu-devel@nongnu.org; Tue, 22 Feb 2011 05:19:48 -0500 From: Amit Shah Date: Tue, 22 Feb 2011 15:48:35 +0530 Message-Id: <119549d84e2a32415d90a1e8b6bc6007b1a3b4a9.1298369272.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 6/7] char: stdio: Use new iohandler api List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Gerd Hoffmann Update the stdio 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 | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index d93820e..ade28ba 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -717,7 +717,7 @@ static void stdio_read(void *opaque) size = read(0, buf, 1); if (size == 0) { /* stdin has been closed. Remove it from the active list. */ - qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); + remove_iohandler(0); qemu_chr_event(chr, CHR_EVENT_CLOSED); return; } @@ -730,6 +730,22 @@ static void stdio_read(void *opaque) } } +static int stdio_iohandler(void *opaque, unsigned int mask) +{ + int ret; + + ret = 0; + switch(mask) { + case IOH_MASK_CAN_READ: + ret = stdio_read_poll(opaque); + break; + case IOH_MASK_READ: + stdio_read(opaque); + break; + } + return ret; +} + /* init terminal so that we can grab keys */ static struct termios oldtty; static int old_fd0_flags; @@ -767,7 +783,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr) { term_exit(); stdio_nb_clients--; - qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); + remove_iohandler(0); fd_chr_close(chr); } @@ -787,7 +803,7 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio; - qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); + assign_iohandler(0, stdio_iohandler, IOH_MASK_CAN_READ|IOH_MASK_READ, chr); stdio_nb_clients++; stdio_allow_signal = qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC); -- 1.7.4