[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/5] iohandlers: Introduce assign_fd_handlers() a
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH v2 2/5] iohandlers: Introduce assign_fd_handlers() and remove_fd_handlers |
Date: |
Thu, 13 Jan 2011 20:30:39 +0530 |
This function will be used to assign fd handlers. Future commits will
be enable each handler to be enabled/disabled individually.
Make qemu_set_fd_handler2() a wrapper to assign_fd_handlers().
remove_fd_handlers() removes all the assigned handlers and marks the
iohandler for deletion. It's a wrapper to assign_fd_handlers() with
NULL handlers.
Signed-off-by: Amit Shah <address@hidden>
---
qemu-char.h | 6 ++++++
vl.c | 36 +++++++++++++++++++++++++++++-------
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/qemu-char.h b/qemu-char.h
index e6ee6c4..0ef83f4 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -109,6 +109,12 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr);
/* async I/O support */
+int assign_fd_handlers(int fd,
+ IOCanReadHandler *fd_read_poll,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque);
+void remove_fd_handlers(int fd);
int qemu_set_fd_handler2(int fd,
IOCanReadHandler *fd_read_poll,
IOHandler *fd_read,
diff --git a/vl.c b/vl.c
index 9e365f6..30256e1 100644
--- a/vl.c
+++ b/vl.c
@@ -1034,13 +1034,17 @@ static IOHandlerRecord *get_iohandler(int fd)
return NULL;
}
-/* XXX: fd_read_poll should be suppressed, but an API change is
- necessary in the character devices to suppress fd_can_read(). */
-int qemu_set_fd_handler2(int fd,
- IOCanReadHandler *fd_read_poll,
- IOHandler *fd_read,
- IOHandler *fd_write,
- void *opaque)
+/*
+ * Specify function pointers for the various IOHandlers for an fd here.
+ *
+ * XXX: fd_read_poll should be suppressed, but an API change is
+ * necessary in the character devices to suppress fd_can_read().
+ */
+int assign_fd_handlers(int fd,
+ IOCanReadHandler *fd_read_poll,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque)
{
IOHandlerRecord *ioh;
@@ -1066,6 +1070,24 @@ int qemu_set_fd_handler2(int fd,
return 0;
}
+/*
+ * Remove IO handlers for fd. Marks the IOHandler, if one exists, for
+ * deletion.
+ */
+void remove_fd_handlers(int fd)
+{
+ assign_fd_handlers(fd, NULL, NULL, NULL, NULL);
+}
+
+int qemu_set_fd_handler2(int fd,
+ IOCanReadHandler *fd_read_poll,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque)
+{
+ return assign_fd_handlers(fd, fd_read_poll, fd_read, fd_write, opaque);
+}
+
int qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
--
1.7.3.4
- [Qemu-devel] [PATCH v2 0/5] iohandlers: Add support for enabling/disabling individual handlers, Amit Shah, 2011/01/13
- [Qemu-devel] [PATCH v2 1/5] iohandlers: Avoid code duplication, Amit Shah, 2011/01/13
- [Qemu-devel] [PATCH v2 2/5] iohandlers: Introduce assign_fd_handlers() and remove_fd_handlers,
Amit Shah <=
- [Qemu-devel] [PATCH v2 3/5] iohandlers: Allow each iohandler to be enabled/disabled individually, Amit Shah, 2011/01/13
- [Qemu-devel] [PATCH v2 4/5] iohandlers: Enable an iohandler only if the associated handler exists, Amit Shah, 2011/01/13
- [Qemu-devel] [PATCH v2 5/5] iohandlers: Add IOHandlerOps struct, Amit Shah, 2011/01/13
- [Qemu-devel] Re: [PATCH v2 0/5] iohandlers: Add support for enabling/disabling individual handlers, Gerd Hoffmann, 2011/01/13
- [Qemu-devel] Re: [PATCH v2 0/5] iohandlers: Add support for enabling/disabling individual handlers, Anthony Liguori, 2011/01/13