From patchwork Wed Nov 10 22:28:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 70726 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 BB6BEB7112 for ; Thu, 11 Nov 2010 10:20:35 +1100 (EST) Received: from localhost ([127.0.0.1]:56127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJU3-0006po-Th for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2010 17:49:39 -0500 Received: from [140.186.70.92] (port=42984 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGJDP-0008M3-Gr for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:32:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGJ9d-0007nl-6o for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:34 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:46159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGJ9c-0007nf-Vg for qemu-devel@nongnu.org; Wed, 10 Nov 2010 17:28:33 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAAMBuIP016879 for ; Wed, 10 Nov 2010 17:11:56 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAAMSWBb275210 for ; Wed, 10 Nov 2010 17:28:32 -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 oAAMSWYP002026 for ; Wed, 10 Nov 2010 17:28:32 -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 oAAMSI5P001385; Wed, 10 Nov 2010 17:28:30 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 10 Nov 2010 16:28:00 -0600 Message-Id: <1289428095-5059-5-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 04/19] virtproxy: list look-up functions conns/oforwards/iforwards 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 Signed-off-by: Michael Roth --- virtproxy.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/virtproxy.c b/virtproxy.c index 3686c77..2cfd905 100644 --- a/virtproxy.c +++ b/virtproxy.c @@ -151,3 +151,47 @@ static QemuOptsList vp_socket_opts = { { /* end if list */ } }, }; + +/* get VPConn by fd, "client" denotes whether to look for client or server */ +static VPConn *get_conn(const VPDriver *drv, int fd, bool client) +{ + VPConn *c = NULL; + int cur_fd; + + QLIST_FOREACH(c, &drv->conns, next) { + cur_fd = client ? c->client_fd : c->server_fd; + if (cur_fd == fd) { + return c; + } + } + + return NULL; +} + +/* get VPOForward by service_id */ +static VPOForward *get_oforward(const VPDriver *drv, const char *service_id) +{ + VPOForward *f = NULL; + + QLIST_FOREACH(f, &drv->oforwards, next) { + if (strncmp(f->service_id, service_id, VP_SERVICE_ID_LEN) == 0) { + return f; + } + } + + return NULL; +} + +/* get VPIForward by service_id */ +static VPIForward *get_iforward(const VPDriver *drv, const char *service_id) +{ + VPIForward *f = NULL; + + QLIST_FOREACH(f, &drv->iforwards, next) { + if (strncmp(f->service_id, service_id, VP_SERVICE_ID_LEN) == 0) { + return f; + } + } + + return NULL; +}