From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58210 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9May-0006ug-Vr for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P9Maw-0001mZ-Ve for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:04 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:53209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P9Maw-0001mT-T2 for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:02 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o9MINEm6021222 for ; Fri, 22 Oct 2010 14:23:14 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9MIi23g134858 for ; Fri, 22 Oct 2010 14:44:02 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o9MIi26l015147 for ; Fri, 22 Oct 2010 14:44:02 -0400 From: Michael Roth Date: Fri, 22 Oct 2010 13:43:25 -0500 Message-Id: <1287773011-24726-10-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1287773011-24726-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1287773011-24726-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH 09/15] virtproxy: add handler for data packets List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Process VPPackets coming in from channel and send them to the appropriate server/client connections. Signed-off-by: Michael Roth --- 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