2012-07-24 19:35:04 +04:00
|
|
|
/*
|
|
|
|
* Hub net client
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
|
|
|
|
* Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
|
|
|
* See the COPYING.LIB file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-29 20:50:00 +03:00
|
|
|
#include "qemu/osdep.h"
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
#include "qapi/error.h"
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "monitor/monitor.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2012-09-17 20:43:51 +04:00
|
|
|
#include "clients.h"
|
2012-07-24 19:35:04 +04:00
|
|
|
#include "hub.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/iov.h"
|
2017-09-11 22:52:50 +03:00
|
|
|
#include "qemu/error-report.h"
|
2018-12-04 06:53:44 +03:00
|
|
|
#include "sysemu/qtest.h"
|
2012-07-24 19:35:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A hub broadcasts incoming packets to all its ports except the source port.
|
2018-04-30 21:02:24 +03:00
|
|
|
* Hubs can be used to provide independent emulated network segments.
|
2012-07-24 19:35:04 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct NetHub NetHub;
|
|
|
|
|
|
|
|
typedef struct NetHubPort {
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState nc;
|
2012-07-24 19:35:04 +04:00
|
|
|
QLIST_ENTRY(NetHubPort) next;
|
|
|
|
NetHub *hub;
|
|
|
|
int id;
|
|
|
|
} NetHubPort;
|
|
|
|
|
|
|
|
struct NetHub {
|
|
|
|
int id;
|
|
|
|
QLIST_ENTRY(NetHub) next;
|
|
|
|
int num_ports;
|
|
|
|
QLIST_HEAD(, NetHubPort) ports;
|
|
|
|
};
|
|
|
|
|
|
|
|
static QLIST_HEAD(, NetHub) hubs = QLIST_HEAD_INITIALIZER(&hubs);
|
|
|
|
|
|
|
|
static ssize_t net_hub_receive(NetHub *hub, NetHubPort *source_port,
|
|
|
|
const uint8_t *buf, size_t len)
|
|
|
|
{
|
|
|
|
NetHubPort *port;
|
|
|
|
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
|
|
|
if (port == source_port) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_send_packet(&port->nc, buf, len);
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t net_hub_receive_iov(NetHub *hub, NetHubPort *source_port,
|
|
|
|
const struct iovec *iov, int iovcnt)
|
|
|
|
{
|
|
|
|
NetHubPort *port;
|
2012-07-24 19:35:19 +04:00
|
|
|
ssize_t len = iov_size(iov, iovcnt);
|
2012-07-24 19:35:04 +04:00
|
|
|
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
|
|
|
if (port == source_port) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:19 +04:00
|
|
|
qemu_sendv_packet(&port->nc, iov, iovcnt);
|
2012-07-24 19:35:04 +04:00
|
|
|
}
|
2012-07-24 19:35:19 +04:00
|
|
|
return len;
|
2012-07-24 19:35:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static NetHub *net_hub_new(int id)
|
|
|
|
{
|
|
|
|
NetHub *hub;
|
|
|
|
|
|
|
|
hub = g_malloc(sizeof(*hub));
|
|
|
|
hub->id = id;
|
|
|
|
hub->num_ports = 0;
|
|
|
|
QLIST_INIT(&hub->ports);
|
|
|
|
|
|
|
|
QLIST_INSERT_HEAD(&hubs, hub, next);
|
|
|
|
|
|
|
|
return hub;
|
|
|
|
}
|
|
|
|
|
2020-03-05 20:56:49 +03:00
|
|
|
static bool net_hub_port_can_receive(NetClientState *nc)
|
2012-07-24 19:35:19 +04:00
|
|
|
{
|
|
|
|
NetHubPort *port;
|
|
|
|
NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
NetHub *hub = src_port->hub;
|
|
|
|
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
|
|
|
if (port == src_port) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-08-24 16:50:30 +04:00
|
|
|
if (qemu_can_send_packet(&port->nc)) {
|
2020-03-05 20:56:49 +03:00
|
|
|
return true;
|
2012-07-24 19:35:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 20:56:49 +03:00
|
|
|
return false;
|
2012-07-24 19:35:19 +04:00
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static ssize_t net_hub_port_receive(NetClientState *nc,
|
2012-07-24 19:35:04 +04:00
|
|
|
const uint8_t *buf, size_t len)
|
|
|
|
{
|
|
|
|
NetHubPort *port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
|
|
|
|
return net_hub_receive(port->hub, port, buf, len);
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static ssize_t net_hub_port_receive_iov(NetClientState *nc,
|
2012-07-24 19:35:04 +04:00
|
|
|
const struct iovec *iov, int iovcnt)
|
|
|
|
{
|
|
|
|
NetHubPort *port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
|
|
|
|
return net_hub_receive_iov(port->hub, port, iov, iovcnt);
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:13 +04:00
|
|
|
static void net_hub_port_cleanup(NetClientState *nc)
|
2012-07-24 19:35:04 +04:00
|
|
|
{
|
|
|
|
NetHubPort *port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
|
|
|
|
QLIST_REMOVE(port, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NetClientInfo net_hub_port_info = {
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
.type = NET_CLIENT_DRIVER_HUBPORT,
|
2012-07-24 19:35:04 +04:00
|
|
|
.size = sizeof(NetHubPort),
|
2012-07-24 19:35:19 +04:00
|
|
|
.can_receive = net_hub_port_can_receive,
|
2012-07-24 19:35:04 +04:00
|
|
|
.receive = net_hub_port_receive,
|
|
|
|
.receive_iov = net_hub_port_receive_iov,
|
|
|
|
.cleanup = net_hub_port_cleanup,
|
|
|
|
};
|
|
|
|
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
static NetHubPort *net_hub_port_new(NetHub *hub, const char *name,
|
|
|
|
NetClientState *hubpeer)
|
2012-07-24 19:35:04 +04:00
|
|
|
{
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState *nc;
|
2012-07-24 19:35:04 +04:00
|
|
|
NetHubPort *port;
|
|
|
|
int id = hub->num_ports++;
|
|
|
|
char default_name[128];
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
snprintf(default_name, sizeof(default_name),
|
|
|
|
"hub%dport%d", hub->id, id);
|
|
|
|
name = default_name;
|
|
|
|
}
|
|
|
|
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
nc = qemu_new_net_client(&net_hub_port_info, hubpeer, "hub", name);
|
2012-07-24 19:35:04 +04:00
|
|
|
port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
port->id = id;
|
|
|
|
port->hub = hub;
|
|
|
|
|
|
|
|
QLIST_INSERT_HEAD(&hub->ports, port, next);
|
|
|
|
|
|
|
|
return port;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a port on a given hub
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
* @hub_id: Number of the hub
|
2012-07-24 19:35:04 +04:00
|
|
|
* @name: Net client name or NULL for default name.
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
* @hubpeer: Peer to use (if "netdev=id" has been specified)
|
2012-07-24 19:35:04 +04:00
|
|
|
*
|
|
|
|
* If there is no existing hub with the given id then a new hub is created.
|
|
|
|
*/
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
NetClientState *net_hub_add_port(int hub_id, const char *name,
|
|
|
|
NetClientState *hubpeer)
|
2012-07-24 19:35:04 +04:00
|
|
|
{
|
|
|
|
NetHub *hub;
|
|
|
|
NetHubPort *port;
|
|
|
|
|
|
|
|
QLIST_FOREACH(hub, &hubs, next) {
|
|
|
|
if (hub->id == hub_id) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hub) {
|
|
|
|
hub = net_hub_new(hub_id);
|
|
|
|
}
|
|
|
|
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
port = net_hub_port_new(hub, name, hubpeer);
|
2012-07-24 19:35:04 +04:00
|
|
|
return &port->nc;
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:09 +04:00
|
|
|
/**
|
|
|
|
* Find a available port on a hub; otherwise create one new port
|
|
|
|
*/
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState *net_hub_port_find(int hub_id)
|
2012-07-24 19:35:09 +04:00
|
|
|
{
|
|
|
|
NetHub *hub;
|
|
|
|
NetHubPort *port;
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState *nc;
|
2012-07-24 19:35:09 +04:00
|
|
|
|
|
|
|
QLIST_FOREACH(hub, &hubs, next) {
|
|
|
|
if (hub->id == hub_id) {
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
|
|
|
nc = port->nc.peer;
|
|
|
|
if (!nc) {
|
|
|
|
return &(port->nc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
nc = net_hub_add_port(hub_id, NULL, NULL);
|
2012-07-24 19:35:09 +04:00
|
|
|
return nc;
|
|
|
|
}
|
|
|
|
|
2012-07-24 19:35:04 +04:00
|
|
|
/**
|
|
|
|
* Print hub configuration
|
|
|
|
*/
|
|
|
|
void net_hub_info(Monitor *mon)
|
|
|
|
{
|
|
|
|
NetHub *hub;
|
|
|
|
NetHubPort *port;
|
|
|
|
|
|
|
|
QLIST_FOREACH(hub, &hubs, next) {
|
|
|
|
monitor_printf(mon, "hub %d\n", hub->id);
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
2015-02-02 10:06:35 +03:00
|
|
|
monitor_printf(mon, " \\ %s", port->nc.name);
|
2012-07-24 19:35:16 +04:00
|
|
|
if (port->nc.peer) {
|
2015-02-02 10:06:35 +03:00
|
|
|
monitor_printf(mon, ": ");
|
2012-07-24 19:35:16 +04:00
|
|
|
print_net_client(mon, port->nc.peer);
|
2015-02-02 10:06:35 +03:00
|
|
|
} else {
|
|
|
|
monitor_printf(mon, "\n");
|
2012-07-24 19:35:16 +04:00
|
|
|
}
|
2012-07-24 19:35:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the hub id that a client is connected to
|
|
|
|
*
|
2012-12-07 05:43:18 +04:00
|
|
|
* @id: Pointer for hub id output, may be NULL
|
2012-07-24 19:35:04 +04:00
|
|
|
*/
|
2012-07-24 19:35:13 +04:00
|
|
|
int net_hub_id_for_client(NetClientState *nc, int *id)
|
2012-07-24 19:35:04 +04:00
|
|
|
{
|
|
|
|
NetHubPort *port;
|
|
|
|
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
if (nc->info->type == NET_CLIENT_DRIVER_HUBPORT) {
|
2012-07-24 19:35:04 +04:00
|
|
|
port = DO_UPCAST(NetHubPort, nc, nc);
|
|
|
|
} else if (nc->peer != NULL && nc->peer->info->type ==
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
NET_CLIENT_DRIVER_HUBPORT) {
|
2012-07-24 19:35:04 +04:00
|
|
|
port = DO_UPCAST(NetHubPort, nc, nc->peer);
|
|
|
|
} else {
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
*id = port->hub->id;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-14 06:50:12 +03:00
|
|
|
int net_init_hubport(const Netdev *netdev, const char *name,
|
2015-05-15 14:58:50 +03:00
|
|
|
NetClientState *peer, Error **errp)
|
2012-07-24 19:35:04 +04:00
|
|
|
{
|
|
|
|
const NetdevHubPortOptions *hubport;
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
NetClientState *hubpeer = NULL;
|
2012-07-24 19:35:04 +04:00
|
|
|
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
assert(netdev->type == NET_CLIENT_DRIVER_HUBPORT);
|
2015-05-15 14:58:49 +03:00
|
|
|
assert(!peer);
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
hubport = &netdev->u.hubport;
|
2012-07-24 19:35:04 +04:00
|
|
|
|
net: Allow hubports to connect to other netdevs
QEMU can emulate hubs to connect NICs and netdevs. This is currently
primarily used for the mis-named 'vlan' feature of the networking
subsystem. Now the 'vlan' feature has been marked as deprecated, since
its name is rather confusing and the users often rather mis-configure
their network when trying to use it. But while the 'vlan' parameter
should be removed at one point in time, the basic idea of emulating
a hub in QEMU is still good: It's useful for bundling up the output of
multiple NICs into one single l2tp netdev for example.
Now to be able to use the hubport feature without 'vlan's, there is one
missing piece: The possibility to connect a hubport to a netdev, too.
This patch adds this possibility by introducing a new "netdev=..."
parameter to the hubports.
To bundle up the output of multiple NICs into one socket netdev, you can
now run QEMU with these parameters for example:
qemu-system-ppc64 ... -netdev socket,id=s1,connect=:11122 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device virtio-net-pci,netdev=h3
For using the socket netdev, you have got to start another QEMU as the
receiving side first, for example with network dumping enabled:
qemu-system-x86_64 -M isapc -netdev socket,id=s0,listen=:11122 \
-device ne2k_isa,netdev=s0 \
-object filter-dump,id=f1,netdev=s0,file=/tmp/dump.dat
After the ppc64 guest tried to boot from both NICs, you can see in the
dump file (using Wireshark, for example), that the output of both NICs
(the e1000 and the virtio-net-pci) has been successfully transfered
via the socket netdev in this case.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2018-01-15 22:50:55 +03:00
|
|
|
if (hubport->has_netdev) {
|
|
|
|
hubpeer = qemu_find_netdev(hubport->netdev);
|
|
|
|
if (!hubpeer) {
|
|
|
|
error_setg(errp, "netdev '%s' not found", hubport->netdev);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
net_hub_add_port(hubport->hubid, name, hubpeer);
|
|
|
|
|
2012-07-24 19:35:04 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2012-07-24 19:35:07 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Warn if hub configurations are likely wrong
|
|
|
|
*/
|
|
|
|
void net_hub_check_clients(void)
|
|
|
|
{
|
|
|
|
NetHub *hub;
|
|
|
|
NetHubPort *port;
|
2012-07-24 19:35:13 +04:00
|
|
|
NetClientState *peer;
|
2012-07-24 19:35:07 +04:00
|
|
|
|
|
|
|
QLIST_FOREACH(hub, &hubs, next) {
|
|
|
|
int has_nic = 0, has_host_dev = 0;
|
|
|
|
|
|
|
|
QLIST_FOREACH(port, &hub->ports, next) {
|
|
|
|
peer = port->nc.peer;
|
|
|
|
if (!peer) {
|
2017-09-11 22:52:56 +03:00
|
|
|
warn_report("hub port %s has no peer", port->nc.name);
|
2012-07-24 19:35:07 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (peer->info->type) {
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
case NET_CLIENT_DRIVER_NIC:
|
2012-07-24 19:35:07 +04:00
|
|
|
has_nic = 1;
|
|
|
|
break;
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 06:50:23 +03:00
|
|
|
case NET_CLIENT_DRIVER_USER:
|
|
|
|
case NET_CLIENT_DRIVER_TAP:
|
|
|
|
case NET_CLIENT_DRIVER_SOCKET:
|
|
|
|
case NET_CLIENT_DRIVER_VDE:
|
|
|
|
case NET_CLIENT_DRIVER_VHOST_USER:
|
2012-07-24 19:35:07 +04:00
|
|
|
has_host_dev = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (has_host_dev && !has_nic) {
|
2018-04-30 21:02:24 +03:00
|
|
|
warn_report("hub %d with no nics", hub->id);
|
2012-07-24 19:35:07 +04:00
|
|
|
}
|
2018-12-04 06:53:44 +03:00
|
|
|
if (has_nic && !has_host_dev && !qtest_enabled()) {
|
2018-04-30 21:02:24 +03:00
|
|
|
warn_report("hub %d is not connected to host network", hub->id);
|
2012-07-24 19:35:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-05 20:53:31 +04:00
|
|
|
|
|
|
|
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) {
|
2013-08-02 23:47:08 +04:00
|
|
|
ret += qemu_net_queue_flush(port->nc.incoming_queue);
|
2013-02-05 20:53:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret ? true : false;
|
|
|
|
}
|