From patchwork Wed Nov 10 22:28:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 70703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F0076B710F for ; Thu, 11 Nov 2010 09:39:41 +1100 (EST) Received: from localhost ([127.0.0.1]:52762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJKN-0006ot-2T for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2010 17:39:39 -0500 Received: from [140.186.70.92] (port=42545 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJDM-0002DV-GT for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGJ9l-0007q2-Qr for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:43 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:48129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGJ9l-0007pq-NM for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:41 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAAMC8fW001363 for ; Wed, 10 Nov 2010 17:12:08 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAAMSekL396764 for ; Wed, 10 Nov 2010 17:28:40 -0500 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 oAAMSee6002670 for ; Wed, 10 Nov 2010 17:28:40 -0500 Received: from localhost.localdomain (sig-9-65-242-217.mts.ibm.com [9.65.242.217]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oAAMSI5V001385; Wed, 10 Nov 2010 17:28:39 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 10 Nov 2010 16:28:06 -0600 Message-Id: <1289428095-5059-11-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1289428095-5059-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1289428095-5059-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: agl@linux.vnet.ibm.com, abeekhof@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, amit.shah@redhat.com Subject: [Qemu-devel] [RFC][PATCH v2 10/19] virtproxy: add handler for data packets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 f189e2c..a0bbe7f 100644 --- a/virtproxy.c +++ b/virtproxy.c @@ -268,6 +268,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; +} + /* process a stream of packets coming in from the channel */ int vp_handle_packet_buf(VPDriver *drv, const void *buf, int count) {