From patchwork Fri Feb 17 04:20:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 141731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5B8D61007D5 for ; Fri, 17 Feb 2012 15:21:09 +1100 (EST) Received: from localhost ([::1]:51778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyFJe-0004Fj-7T for incoming@patchwork.ozlabs.org; Thu, 16 Feb 2012 23:21:02 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyFJY-0004Fe-4m for qemu-devel@nongnu.org; Thu, 16 Feb 2012 23:20:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyFJW-0000fL-KN for qemu-devel@nongnu.org; Thu, 16 Feb 2012 23:20:56 -0500 Received: from e1.ny.us.ibm.com ([32.97.182.141]:39863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyFJW-0000fE-GZ for qemu-devel@nongnu.org; Thu, 16 Feb 2012 23:20:54 -0500 Received: from /spool/local by e1.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Feb 2012 23:20:50 -0500 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e1.ny.us.ibm.com (192.168.1.101) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Feb 2012 23:20:19 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 73D676E8049 for ; Thu, 16 Feb 2012 23:20:17 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1H4KHO0314476 for ; Thu, 16 Feb 2012 23:20:17 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1H4KHw5010281 for ; Fri, 17 Feb 2012 02:20:17 -0200 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q1H4KDA1010184; Fri, 17 Feb 2012 02:20:14 -0200 Received: by us.ibm.com (sSMTP sendmail emulation); Fri, 17 Feb 2012 12:20:09 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Fri, 17 Feb 2012 12:20:08 +0800 Message-Id: <1329452408-13526-1-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12021704-6078-0000-0000-0000080CD04A X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.141 Cc: aliguori@us.ibm.com, Zhi Yong Wu , srini@cisco.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhi Yong Wu As you have known, QEMU upstream currently doesn't support for -netdev socket,listen; This patch makes it work now. Signed-off-by: Zhi Yong Wu --- net/socket.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/net/socket.c b/net/socket.c index d4c2002..f82e69d 100644 --- a/net/socket.c +++ b/net/socket.c @@ -43,6 +43,7 @@ typedef struct NetSocketState { } NetSocketState; typedef struct NetSocketListenState { + VLANClientState *nc; VLANState *vlan; char *model; char *name; @@ -389,6 +390,11 @@ static void net_socket_accept(void *opaque) break; } } + + if (s->nc) { + qemu_del_vlan_client(s->nc); + } + s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1); if (s1) { snprintf(s1->nc.info_str, sizeof(s1->nc.info_str), @@ -397,6 +403,13 @@ static void net_socket_accept(void *opaque) } } +static NetClientInfo net_listen_info = { + .type = NET_CLIENT_TYPE_NONE, + .size = sizeof(VLANClientState), + .receive = NULL, + .cleanup = NULL, +}; + static int net_socket_listen_init(VLANState *vlan, const char *model, const char *name, @@ -441,6 +454,10 @@ static int net_socket_listen_init(VLANState *vlan, s->model = g_strdup(model); s->name = name ? g_strdup(name) : NULL; s->fd = fd; + + s->nc = qemu_new_net_client(&net_listen_info, NULL, NULL, model, name); + s->nc->link_down = true; + qemu_set_fd_handler(fd, net_socket_accept, NULL, s); return 0; }