summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-11-04 15:46:33 +0000
committerMichael Roth <mdroth@linux.vnet.ibm.com>2016-11-18 19:06:19 -0600
commit95a0638043d377bccbac5c9f2c0e6322e407e96f (patch)
treeb182318ecaa7cb758d6de16c1f247dd6852d01ee
parent1790a9d77d5d063f720907bec3fdb9b5a5e11d65 (diff)
downloadqemu-95a0638043d377bccbac5c9f2c0e6322e407e96f.tar.gz
net: fix sending of data with -net socket, listen backend
The use of -net socket,listen was broken in the following commit commit 16a3df403b10c4ac347159e39005fd520b2648bb Author: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> Date: Fri May 13 15:35:19 2016 +0800 net/net: Add SocketReadState for reuse codes This function is from net/socket.c, move it to net.c and net.h. Add SocketReadState to make others reuse net_fill_rstate(). suggestion from jason. This refactored the state out of NetSocketState into a separate SocketReadState. This refactoring requires that a callback is provided to be triggered upon completion of a packet receive from the guest. The patch only registered this callback in the codepaths hit by -net socket,connect, not -net socket,listen. So as a result packets sent by the guest in the latter case get dropped on the floor. This bug is hidden because net_fill_rstate() silently does nothing if the callback is not set. This patch adds in the middle callback registration and also adds an assert so that QEMU aborts if there are any other codepaths hit which are missing the callback. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> Signed-off-by: Jason Wang <jasowang@redhat.com> (cherry picked from commit e79cd4068063ea2859199002a049010a11202939) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--net/net.c5
-rw-r--r--net/socket.c1
2 files changed, 3 insertions, 3 deletions
diff --git a/net/net.c b/net/net.c
index d51cb29882..19b4d9e367 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1648,9 +1648,8 @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
if (rs->index >= rs->packet_len) {
rs->index = 0;
rs->state = 0;
- if (rs->finalize) {
- rs->finalize(rs);
- }
+ assert(rs->finalize);
+ rs->finalize(rs);
}
break;
}
diff --git a/net/socket.c b/net/socket.c
index 3f98eefb34..dcae1ae2c0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -522,6 +522,7 @@ static int net_socket_listen_init(NetClientState *peer,
s->fd = -1;
s->listen_fd = fd;
s->nc.link_down = true;
+ net_socket_rs_init(&s->rs, net_socket_rs_finalize);
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
return 0;