#include "hub.h"
#include "qemu/iov.h"
#include "qemu/error-report.h"
+#include "sysemu/qtest.h"
/*
* A hub broadcasts incoming packets to all its ports except the source port.
- * Hubs can be used to provide independent network segments, also confusingly
- * named the QEMU 'vlan' feature.
+ * Hubs can be used to provide independent emulated network segments.
*/
typedef struct NetHub NetHub;
return hub;
}
-static int net_hub_port_can_receive(NetClientState *nc)
+static bool net_hub_port_can_receive(NetClientState *nc)
{
NetHubPort *port;
NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
}
if (qemu_can_send_packet(&port->nc)) {
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
static ssize_t net_hub_port_receive(NetClientState *nc,
return &port->nc;
}
-/**
- * Find a specific client on a hub
- */
-NetClientState *net_hub_find_client_by_name(int hub_id, const char *name)
-{
- NetHub *hub;
- NetHubPort *port;
- NetClientState *peer;
-
- QLIST_FOREACH(hub, &hubs, next) {
- if (hub->id == hub_id) {
- QLIST_FOREACH(port, &hub->ports, next) {
- peer = port->nc.peer;
-
- if (peer && strcmp(peer->name, name) == 0) {
- return peer;
- }
- }
- }
- }
- return NULL;
-}
-
/**
* Find a available port on a hub; otherwise create one new port
*/
assert(!peer);
hubport = &netdev->u.hubport;
- if (hubport->has_netdev) {
+ if (hubport->netdev) {
hubpeer = qemu_find_netdev(hubport->netdev);
if (!hubpeer) {
error_setg(errp, "netdev '%s' not found", hubport->netdev);
case NET_CLIENT_DRIVER_USER:
case NET_CLIENT_DRIVER_TAP:
case NET_CLIENT_DRIVER_SOCKET:
+ case NET_CLIENT_DRIVER_STREAM:
+ case NET_CLIENT_DRIVER_DGRAM:
case NET_CLIENT_DRIVER_VDE:
case NET_CLIENT_DRIVER_VHOST_USER:
has_host_dev = 1;
}
}
if (has_host_dev && !has_nic) {
- warn_report("vlan %d with no nics", hub->id);
+ warn_report("hub %d with no nics", hub->id);
}
- if (has_nic && !has_host_dev) {
- warn_report("vlan %d is not connected to host network", hub->id);
+ if (has_nic && !has_host_dev && !qtest_enabled()) {
+ warn_report("hub %d is not connected to host network", hub->id);
}
}
}