From patchwork Fri Oct 22 18:43:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 68922 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 59D50B70CC for ; Sat, 23 Oct 2010 06:07:18 +1100 (EST) Received: from localhost ([127.0.0.1]:58764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9MxO-0002Cl-TL for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2010 15:07:14 -0400 Received: from [140.186.70.92] (port=58438 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9MbB-00075A-Jd for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P9Mb8-0001r9-6a for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:16 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:53177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P9Mb7-0001kb-Sj for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:14 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o9MIN72B021039 for ; Fri, 22 Oct 2010 14:23:07 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9MIhsKv2347110 for ; Fri, 22 Oct 2010 14:43:54 -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 o9MIhsSf014846 for ; Fri, 22 Oct 2010 14:43:54 -0400 Received: from localhost.localdomain (sig-9-76-202-211.mts.ibm.com [9.76.202.211]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o9MIhchr013644; Fri, 22 Oct 2010 14:43:53 -0400 From: Michael Roth To: qemu-devel@nongnu.org Date: Fri, 22 Oct 2010 13:43:20 -0500 Message-Id: <1287773011-24726-5-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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 04/15] 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 2f8996c..fa17722 100644 --- a/virtproxy.c +++ b/virtproxy.c @@ -149,3 +149,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; +}