From: Zhi Yong Wu <wu...@linux.vnet.ibm.com> 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 <wu...@linux.vnet.ibm.com> --- 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; } -- 1.7.6