From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: zwu.kernel@gmail.com
Cc: aliguori@us.ibm.com, Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
srini@cisco.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] socket: add the support for -netdev socket, listen
Date: Fri, 17 Feb 2012 10:24:14 +0000 [thread overview]
Message-ID: <20120217102414.GA24722@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1329452408-13526-1-git-send-email-zwu.kernel@gmail.com>
On Fri, Feb 17, 2012 at 12:20:08PM +0800, zwu.kernel@gmail.com wrote:
> 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.
This commit description does not give any context. Please explain what
the bug is so readers know what this patch fixes.
I tried the following test:
$ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -m 1024 \
-drive if=virtio,file=vm1.img,cache=none \
-netdev socket,listen=127.0.0.1:1234,id=socket0 \
-device virtio-net-pci,netdev=socket0
$ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -m 1024 \
-drive if=virtio,file=vm2.img,cache=none \
-netdev socket,connect=127.0.0.1:1234,id=socket0 \
-device virtio-net-pci,netdev=socket0
The first thing I noticed was that the output of "info network" in vm1
looks wrong. It should show the virtio-net-pci NIC peered with a socket
fd connection. Instead it shows it peered with a dummy VLANClientState
and I see two socket fds with no peers.
Network connectivity between the two QEMUs does not work. I assigned
static IPs in both VMs, ran tcpdump in vm1, and then tried to ping vm1
from vm2.
> 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);
This has a few issues:
net_socket_fd_init() does not set the peer, only vlan. This means the
connected socket and NIC are not peered up.
qemu_del_vlan_client() brings the link down...we never bring it back up.
We need to avoid leaking s->nc because it is not freed in
qemu_del_vlan_client(). Once peering is fixed s->nc will not be freed
during NIC deletion anymore!
It leaves a dangling pointer to s->nc in the qdev netdev property and
NICInfo nd_table[]. Not sure if this is a problem but it's messy.
I suggest using the real NetSocketState instead - do not create a dummy
VLANClientState. This means we create the socket fd NetSocketState
right away and never need to update the peer. Simply bring the link up
once the socket file descriptor is connected.
Stefan
next prev parent reply other threads:[~2012-02-17 10:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20120217102414.GA24722@stefanha-thinkpad.localdomain \
--to=stefanha@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=srini@cisco.com \
--cc=wuzhy@linux.vnet.ibm.com \
--cc=zwu.kernel@gmail.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).