qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: zwu.kernel@gmail.com
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
	srini@cisco.com, stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen
Date: Fri, 17 Feb 2012 12:20:08 +0800	[thread overview]
Message-ID: <1329452408-13526-1-git-send-email-zwu.kernel@gmail.com> (raw)

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

             reply	other threads:[~2012-02-17  4:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17  4:20 zwu.kernel [this message]
2012-02-17 10:24 ` [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329452408-13526-1-git-send-email-zwu.kernel@gmail.com \
    --to=zwu.kernel@gmail.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=srini@cisco.com \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=wuzhy@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).