qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen
@ 2012-02-17  4:20 zwu.kernel
  2012-02-17 10:24 ` Stefan Hajnoczi
  0 siblings, 1 reply; 8+ messages in thread
From: zwu.kernel @ 2012-02-17  4:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Zhi Yong Wu, srini, stefanha

From: Zhi Yong Wu <wuzhy@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 <wuzhy@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-18 10:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17  4:20 [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen zwu.kernel
2012-02-17 10:24 ` Stefan Hajnoczi
2012-02-18  5:35   ` Zhi Yong Wu
2012-02-18 10:06     ` Stefan Hajnoczi
2012-02-18 10:51       ` Zhi Yong Wu
2012-02-18  8:54   ` Zhi Yong Wu
2012-02-18  9:52     ` Stefan Hajnoczi
2012-02-18 10:47       ` Zhi Yong Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).