[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH 07/15] virtproxy: add vp_new() VPDriver constru
From: |
Michael Roth |
Subject: |
[Qemu-devel] [RFC][PATCH 07/15] virtproxy: add vp_new() VPDriver constructor |
Date: |
Fri, 22 Oct 2010 13:43:23 -0500 |
Signed-off-by: Michael Roth <address@hidden>
---
virtproxy.c | 23 +++++++++++++++++++++++
virtproxy.h | 3 +++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/virtproxy.c b/virtproxy.c
index c9c3022..cc0ac9a 100644
--- a/virtproxy.c
+++ b/virtproxy.c
@@ -313,3 +313,26 @@ static void vp_channel_read(void *opaque)
drv->buflen += count;
}
}
+
+/* create/init VPDriver object */
+VPDriver *vp_new(int fd, bool listen)
+{
+ VPDriver *drv = NULL;
+
+ drv = qemu_mallocz(sizeof(VPDriver));
+ drv->listen_fd = -1;
+ drv->channel_fd = -1;
+ QLIST_INIT(&drv->oforwards);
+ QLIST_INIT(&drv->conns);
+
+ if (listen) {
+ /* provided FD is to be listened on for channel connection */
+ drv->listen_fd = fd;
+ vp_set_fd_handler(drv->listen_fd, vp_channel_accept, NULL, drv);
+ } else {
+ drv->channel_fd = fd;
+ vp_set_fd_handler(drv->channel_fd, vp_channel_read, NULL, drv);
+ }
+
+ return drv;
+}
diff --git a/virtproxy.h b/virtproxy.h
index 0203421..3df1691 100644
--- a/virtproxy.h
+++ b/virtproxy.h
@@ -31,4 +31,7 @@ int vp_set_fd_handler(int fd,
IOHandler *fd_write,
void *opaque);
+/* virtproxy interface */
+VPDriver *vp_new(int fd, bool listen);
+
#endif /* VIRTPROXY_H */
--
1.7.0.4
- [Qemu-devel] [RFC][PATCH 00/15] virtproxy: host/guest communication layer, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 06/15] virtproxy: add read handler for communication channel, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 02/15] virtproxy: qemu-vp, standalone daemon skeleton, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 07/15] virtproxy: add vp_new() VPDriver constructor,
Michael Roth <=
- [Qemu-devel] [RFC][PATCH 03/15] virtproxy: add debug functions for virtproxy core, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 08/15] virtproxy: interfaces to set/remove/handle VPOForwards, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 09/15] virtproxy: add handler for data packets, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 10/15] virtproxy: add handler for control packet, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 11/15] virtproxy: add vp_handle_packet(), Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 12/15] virtproxy: interfaces to set/remove VPIForwards, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 01/15] virtproxy: base data structures and constants, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 13/15] virtproxy: add read handler for proxied connections, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 15/15] virtproxy: qemu-vp, main logic, Michael Roth, 2010/10/22
- [Qemu-devel] [RFC][PATCH 04/15] virtproxy: list look-up functions conns/oforwards/iforwards, Michael Roth, 2010/10/22