qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com,
	agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com,
	abeekhof@redhat.com
Subject: [Qemu-devel] [RFC][PATCH 09/15] virtproxy: add handler for data packets
Date: Fri, 22 Oct 2010 13:43:25 -0500	[thread overview]
Message-ID: <1287773011-24726-10-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1287773011-24726-1-git-send-email-mdroth@linux.vnet.ibm.com>

Process VPPackets coming in from channel and send them to the
appropriate server/client connections.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 virtproxy.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/virtproxy.c b/virtproxy.c
index 6c3611b..57ab2b0 100644
--- a/virtproxy.c
+++ b/virtproxy.c
@@ -235,6 +235,48 @@ static void vp_channel_accept(void *opaque)
     vp_set_fd_handler(drv->listen_fd, NULL, NULL, NULL);
 }
 
+/* handle data packets
+ *
+ * process VPPackets containing data and send them to the corresponding
+ * FDs
+ */
+static int vp_handle_data_packet(void *drv, const VPPacket *pkt)
+{
+    int fd, ret;
+
+    TRACE("called with drv: %p", drv);
+
+    if (pkt->type == VP_PKT_CLIENT) {
+        TRACE("recieved client packet, client fd: %d, server fd: %d",
+              pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
+        fd = pkt->payload.proxied.server_fd;
+    } else if (pkt->type == VP_PKT_SERVER) {
+        TRACE("recieved server packet, client fd: %d, server fd: %d",
+              pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
+        fd = pkt->payload.proxied.client_fd;
+    } else {
+        TRACE("unknown packet type");
+        return -1;
+    }
+
+    /* TODO: proxied in non-blocking mode can causes us to spin here
+     * for slow servers/clients. need to use write()'s and maintain
+     * a per-conn write queue that we clear out before sending any
+     * more data to the fd
+     */
+    ret = vp_send_all(fd, (void *)pkt->payload.proxied.data,
+            pkt->payload.proxied.bytes);
+    if (ret == -1) {
+        LOG("error sending data over channel");
+        return -1;
+    } else if (ret != pkt->payload.proxied.bytes) {
+        TRACE("buffer full?");
+        return -1;
+    }
+
+    return 0;
+}
+
 /* read handler for communication channel
  *
  * de-multiplexes data coming in over the channel. for control messages
-- 
1.7.0.4

  parent reply	other threads:[~2010-10-22 18:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 18:43 [Qemu-devel] [RFC][PATCH 00/15] virtproxy: host/guest communication layer Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 01/15] virtproxy: base data structures and constants Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 02/15] virtproxy: qemu-vp, standalone daemon skeleton Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 03/15] virtproxy: add debug functions for virtproxy core Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 04/15] virtproxy: list look-up functions conns/oforwards/iforwards Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 05/15] virtproxy: add accept handler for communication channel Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 06/15] virtproxy: add read " Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 07/15] virtproxy: add vp_new() VPDriver constructor Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 08/15] virtproxy: interfaces to set/remove/handle VPOForwards Michael Roth
2010-10-22 18:43 ` Michael Roth [this message]
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 10/15] virtproxy: add handler for control packet Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 11/15] virtproxy: add vp_handle_packet() Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 12/15] virtproxy: interfaces to set/remove VPIForwards Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 13/15] virtproxy: add read handler for proxied connections Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 14/15] virtproxy: Makefile/configure changes to build qemu-vp Michael Roth
2010-10-22 18:43 ` [Qemu-devel] [RFC][PATCH 15/15] virtproxy: qemu-vp, main logic Michael Roth
2010-10-23 11:26 ` [Qemu-devel] [RFC][PATCH 00/15] virtproxy: host/guest communication layer Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287773011-24726-10-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=abeekhof@redhat.com \
    --cc=agl@linux.vnet.ibm.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ryanh@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).