diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-03-21 20:32:58 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2011-05-03 15:56:33 +0200 |
commit | c1f5760e6496840fc98f723aaa863cc9d08de14a (patch) | |
tree | afce2490f11ae37be16b7b51e07841378b42a4de | |
parent | d407a2d4d033a15946003586ca7df649bfbf8eed (diff) |
iohandlers: Add enable/disable_write_fd_handler() functions
These will be used to provide a cleaner API for the nonblocking case.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | iohandler.c | 35 | ||||
-rw-r--r-- | qemu-char.h | 3 |
2 files changed, 38 insertions, 0 deletions
diff --git a/iohandler.c b/iohandler.c index 2b824218e5..8e6628ba9b 100644 --- a/iohandler.c +++ b/iohandler.c @@ -44,6 +44,41 @@ typedef struct IOHandlerRecord { static QLIST_HEAD(, IOHandlerRecord) io_handlers = QLIST_HEAD_INITIALIZER(io_handlers); +static IOHandlerRecord *find_iohandler(int fd) +{ + IOHandlerRecord *ioh; + + QLIST_FOREACH(ioh, &io_handlers, next) { + if (ioh->fd == fd) { + return ioh; + } + } + return NULL; +} + +void enable_write_fd_handler(int fd, IOHandler *fd_write) +{ + IOHandlerRecord *ioh; + + ioh = find_iohandler(fd); + if (!ioh) { + return; + } + + ioh->fd_write = fd_write; +} + +void disable_write_fd_handler(int fd) +{ + IOHandlerRecord *ioh; + + ioh = find_iohandler(fd); + if (!ioh) { + return; + } + + ioh->fd_write = NULL; +} /* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ diff --git a/qemu-char.h b/qemu-char.h index d326834cb1..c1071e6964 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -117,6 +117,9 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr); /* async I/O support */ +void enable_write_fd_handler(int fd, IOHandler *fd_write); +void disable_write_fd_handler(int fd); + int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, IOHandler *fd_read, |