diff options
author | Luigi Rizzo <rizzo@iet.unipi.it> | 2013-02-05 17:53:31 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-02-27 16:10:23 +0100 |
commit | 199ee608f0d08510b5c6c37f31a7fbff211d63c4 (patch) | |
tree | 62d264bb698419fdc701bd11830d47d905cab9e8 /net | |
parent | ee24aaf356f44ca7c8fbef136a438c12091cffd0 (diff) | |
download | qemu-199ee608f0d08510b5c6c37f31a7fbff211d63c4.zip qemu-199ee608f0d08510b5c6c37f31a7fbff211d63c4.tar.gz qemu-199ee608f0d08510b5c6c37f31a7fbff211d63c4.tar.bz2 |
net: fix qemu_flush_queued_packets() in presence of a hub
When frontend and backend are connected through a hub as below
(showing only one direction), and the frontend (or in general, all
output ports of the hub) cannot accept more traffic, the backend
queues packets in queue-A.
When the frontend (or in general, one output port) becomes ready again,
quemu tries to flush packets from queue-B, which is unfortunately empty.
e1000.0 <--[queue B]-- hub0port0(hub)hub0port1 <--[queue A]-- tap.0
To fix this i propose to introduce a new function net_hub_flush()
which is called when trying to flush a queue connected to a hub.
Signed-off-by: Luigi Rizzo <rizzo@iet.unipi.it>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/hub.c | 14 | ||||
-rw-r--r-- | net/hub.h | 1 | ||||
-rw-r--r-- | net/net.c | 6 |
3 files changed, 21 insertions, 0 deletions
@@ -338,3 +338,17 @@ void net_hub_check_clients(void) } } } + +bool net_hub_flush(NetClientState *nc) +{ + NetHubPort *port; + NetHubPort *source_port = DO_UPCAST(NetHubPort, nc, nc); + int ret = 0; + + QLIST_FOREACH(port, &source_port->hub->ports, next) { + if (port != source_port) { + ret += qemu_net_queue_flush(port->nc.send_queue); + } + } + return ret ? true : false; +} @@ -21,5 +21,6 @@ NetClientState *net_hub_add_port(int hub_id, const char *name); NetClientState *net_hub_find_client_by_name(int hub_id, const char *name); void net_hub_info(Monitor *mon); void net_hub_check_clients(void); +bool net_hub_flush(NetClientState *nc); #endif /* NET_HUB_H */ @@ -441,6 +441,12 @@ void qemu_flush_queued_packets(NetClientState *nc) { nc->receive_disabled = 0; + if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (net_hub_flush(nc->peer)) { + qemu_notify_event(); + } + return; + } if (qemu_net_queue_flush(nc->send_queue)) { /* We emptied the queue successfully, signal to the IO thread to repoll * the file descriptor (for tap, for example). |