[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/7] char: stdio: Use new iohandler api
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH 6/7] char: stdio: Use new iohandler api |
Date: |
Tue, 22 Feb 2011 15:48:35 +0530 |
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 <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, (continued)
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Avi Kivity, 2011/02/22
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Amit Shah, 2011/02/22
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Anthony Liguori, 2011/02/22
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Avi Kivity, 2011/02/22
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Anthony Liguori, 2011/02/22
- Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API, Avi Kivity, 2011/02/23
[Qemu-devel] Re: [PATCH 2/7] iohandlers: Introduce a new API, Anthony Liguori, 2011/02/22
[Qemu-devel] [PATCH 3/7] char: tcp: Use new iohandler api, Amit Shah, 2011/02/22
[Qemu-devel] [PATCH 4/7] char: udp: Use new iohandler api, Amit Shah, 2011/02/22
[Qemu-devel] [PATCH 5/7] char: fd: Use new iohandler api, Amit Shah, 2011/02/22
[Qemu-devel] [PATCH 6/7] char: stdio: Use new iohandler api,
Amit Shah <=
[Qemu-devel] [PATCH 7/7] char: pty: Use new iohandler api, Amit Shah, 2011/02/22