1 From 2ac23d2134611b4e5b0fb389911bd03baa685df3 Mon Sep 17 00:00:00 2001
2 From: Amit Shah <amit.shah@redhat.com>
3 Date: Mon, 21 Mar 2011 20:32:58 +0100
4 Subject: [PATCH] iohandlers: Add enable/disable_write_fd_handler() functions
6 These will be used to provide a cleaner API for the nonblocking case.
8 Signed-off-by: Amit Shah <amit.shah@redhat.com>
9 Signed-off-by: Cole Robinson <crobinso@redhat.com>
11 iohandler.c | 35 +++++++++++++++++++++++++++++++++++
13 2 files changed, 38 insertions(+)
15 diff --git a/iohandler.c b/iohandler.c
16 index a2d871b..c00fecd 100644
19 @@ -45,6 +45,41 @@ typedef struct IOHandlerRecord {
20 static QLIST_HEAD(, IOHandlerRecord) io_handlers =
21 QLIST_HEAD_INITIALIZER(io_handlers);
23 +static IOHandlerRecord *find_iohandler(int fd)
25 + IOHandlerRecord *ioh;
27 + QLIST_FOREACH(ioh, &io_handlers, next) {
28 + if (ioh->fd == fd) {
35 +void enable_write_fd_handler(int fd, IOHandler *fd_write)
37 + IOHandlerRecord *ioh;
39 + ioh = find_iohandler(fd);
44 + ioh->fd_write = fd_write;
47 +void disable_write_fd_handler(int fd)
49 + IOHandlerRecord *ioh;
51 + ioh = find_iohandler(fd);
56 + ioh->fd_write = NULL;
59 /* XXX: fd_read_poll should be suppressed, but an API change is
60 necessary in the character devices to suppress fd_can_read(). */
61 diff --git a/main-loop.h b/main-loop.h
62 index dce1cd9..eb31273 100644
65 @@ -175,6 +175,9 @@ typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
66 typedef int IOCanReadHandler(void *opaque);
67 typedef void IOHandler(void *opaque);
69 +void enable_write_fd_handler(int fd, IOHandler *fd_write);
70 +void disable_write_fd_handler(int fd);
73 * qemu_set_fd_handler2: Register a file descriptor with the main loop