mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-15 22:20:45 +00:00
hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)
NET_CLIENT_TYPE_ -> NET_CLIENT_OPTIONS_KIND_ Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
This commit is contained in:
parent
14aa0c2de0
commit
2be64a68ed
@ -1161,7 +1161,7 @@ static void gem_set_link(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_gem_info = {
|
static NetClientInfo net_gem_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = gem_can_receive,
|
.can_receive = gem_can_receive,
|
||||||
.receive = gem_receive,
|
.receive = gem_receive,
|
||||||
|
@ -872,7 +872,7 @@ static void nic_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_dp83932_info = {
|
static NetClientInfo net_dp83932_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = nic_can_receive,
|
.can_receive = nic_can_receive,
|
||||||
.receive = nic_receive,
|
.receive = nic_receive,
|
||||||
|
@ -1206,7 +1206,7 @@ pci_e1000_uninit(PCIDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_e1000_info = {
|
static NetClientInfo net_e1000_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = e1000_can_receive,
|
.can_receive = e1000_can_receive,
|
||||||
.receive = e1000_receive,
|
.receive = e1000_receive,
|
||||||
|
@ -1845,7 +1845,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_eepro100_info = {
|
static NetClientInfo net_eepro100_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = nic_can_receive,
|
.can_receive = nic_can_receive,
|
||||||
.receive = nic_receive,
|
.receive = nic_receive,
|
||||||
|
@ -579,7 +579,7 @@ static void eth_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_etraxfs_info = {
|
static NetClientInfo net_etraxfs_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = eth_can_receive,
|
.can_receive = eth_can_receive,
|
||||||
.receive = eth_receive,
|
.receive = eth_receive,
|
||||||
|
@ -1310,7 +1310,7 @@ static void lan9118_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_lan9118_info = {
|
static NetClientInfo net_lan9118_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = lan9118_can_receive,
|
.can_receive = lan9118_can_receive,
|
||||||
.receive = lan9118_receive,
|
.receive = lan9118_receive,
|
||||||
|
@ -93,7 +93,7 @@ static void lance_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_lance_info = {
|
static NetClientInfo net_lance_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = pcnet_can_receive,
|
.can_receive = pcnet_can_receive,
|
||||||
.receive = pcnet_receive,
|
.receive = pcnet_receive,
|
||||||
|
@ -450,7 +450,7 @@ static void mcf_fec_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_mcf_fec_info = {
|
static NetClientInfo net_mcf_fec_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = mcf_fec_can_receive,
|
.can_receive = mcf_fec_can_receive,
|
||||||
.receive = mcf_fec_receive,
|
.receive = mcf_fec_receive,
|
||||||
|
@ -448,7 +448,7 @@ static void milkymist_minimac2_reset(DeviceState *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_milkymist_minimac2_info = {
|
static NetClientInfo net_milkymist_minimac2_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = minimac2_can_rx,
|
.can_receive = minimac2_can_rx,
|
||||||
.receive = minimac2_rx,
|
.receive = minimac2_rx,
|
||||||
|
@ -217,7 +217,7 @@ static void mipsnet_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_mipsnet_info = {
|
static NetClientInfo net_mipsnet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = mipsnet_can_receive,
|
.can_receive = mipsnet_can_receive,
|
||||||
.receive = mipsnet_receive,
|
.receive = mipsnet_receive,
|
||||||
|
@ -374,7 +374,7 @@ static void eth_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_mv88w8618_info = {
|
static NetClientInfo net_mv88w8618_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = eth_can_receive,
|
.can_receive = eth_can_receive,
|
||||||
.receive = eth_receive,
|
.receive = eth_receive,
|
||||||
|
@ -44,7 +44,7 @@ static void isa_ne2000_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_ne2000_isa_info = {
|
static NetClientInfo net_ne2000_isa_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = ne2000_can_receive,
|
.can_receive = ne2000_can_receive,
|
||||||
.receive = ne2000_receive,
|
.receive = ne2000_receive,
|
||||||
|
@ -711,7 +711,7 @@ static void ne2000_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_ne2000_info = {
|
static NetClientInfo net_ne2000_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = ne2000_can_receive,
|
.can_receive = ne2000_can_receive,
|
||||||
.receive = ne2000_receive,
|
.receive = ne2000_receive,
|
||||||
|
@ -467,7 +467,7 @@ static void open_eth_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_open_eth_info = {
|
static NetClientInfo net_open_eth_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = open_eth_can_receive,
|
.can_receive = open_eth_can_receive,
|
||||||
.receive = open_eth_receive,
|
.receive = open_eth_receive,
|
||||||
|
@ -284,7 +284,7 @@ static int pci_pcnet_uninit(PCIDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_pci_pcnet_info = {
|
static NetClientInfo net_pci_pcnet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = pcnet_can_receive,
|
.can_receive = pcnet_can_receive,
|
||||||
.receive = pcnet_receive,
|
.receive = pcnet_receive,
|
||||||
|
@ -3455,7 +3455,7 @@ static int pci_rtl8139_uninit(PCIDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_rtl8139_info = {
|
static NetClientInfo net_rtl8139_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = rtl8139_can_receive,
|
.can_receive = rtl8139_can_receive,
|
||||||
.receive = rtl8139_receive,
|
.receive = rtl8139_receive,
|
||||||
|
@ -736,7 +736,7 @@ static void smc91c111_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_smc91c111_info = {
|
static NetClientInfo net_smc91c111_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = smc91c111_can_receive,
|
.can_receive = smc91c111_can_receive,
|
||||||
.receive = smc91c111_receive,
|
.receive = smc91c111_receive,
|
||||||
|
@ -176,7 +176,7 @@ static ssize_t spapr_vlan_receive(VLANClientState *nc, const uint8_t *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_spapr_vlan_info = {
|
static NetClientInfo net_spapr_vlan_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = spapr_vlan_can_receive,
|
.can_receive = spapr_vlan_can_receive,
|
||||||
.receive = spapr_vlan_receive,
|
.receive = spapr_vlan_receive,
|
||||||
|
@ -393,7 +393,7 @@ static void stellaris_enet_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_stellaris_enet_info = {
|
static NetClientInfo net_stellaris_enet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = stellaris_enet_can_receive,
|
.can_receive = stellaris_enet_can_receive,
|
||||||
.receive = stellaris_enet_receive,
|
.receive = stellaris_enet_receive,
|
||||||
|
@ -1313,7 +1313,7 @@ static void usb_net_handle_destroy(USBDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_usbnet_info = {
|
static NetClientInfo net_usbnet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = usbnet_can_receive,
|
.can_receive = usbnet_can_receive,
|
||||||
.receive = usbnet_receive,
|
.receive = usbnet_receive,
|
||||||
|
@ -83,7 +83,7 @@ void vhost_net_ack_features(struct vhost_net *net, unsigned features)
|
|||||||
static int vhost_net_get_fd(VLANClientState *backend)
|
static int vhost_net_get_fd(VLANClientState *backend)
|
||||||
{
|
{
|
||||||
switch (backend->info->type) {
|
switch (backend->info->type) {
|
||||||
case NET_CLIENT_TYPE_TAP:
|
case NET_CLIENT_OPTIONS_KIND_TAP:
|
||||||
return tap_get_fd(backend);
|
return tap_get_fd(backend);
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "vhost-net requires tap backend\n");
|
fprintf(stderr, "vhost-net requires tap backend\n");
|
||||||
|
@ -108,7 +108,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
|
|||||||
if (!n->nic->nc.peer) {
|
if (!n->nic->nc.peer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) {
|
if (n->nic->nc.peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ static int peer_has_vnet_hdr(VirtIONet *n)
|
|||||||
if (!n->nic->nc.peer)
|
if (!n->nic->nc.peer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP)
|
if (n->nic->nc.peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer);
|
n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer);
|
||||||
@ -249,7 +249,7 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!n->nic->nc.peer ||
|
if (!n->nic->nc.peer ||
|
||||||
n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) {
|
n->nic->nc.peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
if (!tap_get_vhost_net(n->nic->nc.peer)) {
|
if (!tap_get_vhost_net(n->nic->nc.peer)) {
|
||||||
@ -288,7 +288,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
|
|||||||
(features >> VIRTIO_NET_F_GUEST_UFO) & 1);
|
(features >> VIRTIO_NET_F_GUEST_UFO) & 1);
|
||||||
}
|
}
|
||||||
if (!n->nic->nc.peer ||
|
if (!n->nic->nc.peer ||
|
||||||
n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) {
|
n->nic->nc.peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!tap_get_vhost_net(n->nic->nc.peer)) {
|
if (!tap_get_vhost_net(n->nic->nc.peer)) {
|
||||||
@ -988,7 +988,7 @@ static void virtio_net_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_virtio_info = {
|
static NetClientInfo net_virtio_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = virtio_net_can_receive,
|
.can_receive = virtio_net_can_receive,
|
||||||
.receive = virtio_net_receive,
|
.receive = virtio_net_receive,
|
||||||
|
@ -301,7 +301,7 @@ static ssize_t net_rx_packet(VLANClientState *nc, const uint8_t *buf, size_t siz
|
|||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
static NetClientInfo net_xen_info = {
|
static NetClientInfo net_xen_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = net_rx_ok,
|
.can_receive = net_rx_ok,
|
||||||
.receive = net_rx_packet,
|
.receive = net_rx_packet,
|
||||||
|
@ -371,7 +371,7 @@ static void eth_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_xgmac_enet_info = {
|
static NetClientInfo net_xgmac_enet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = eth_can_rx,
|
.can_receive = eth_can_rx,
|
||||||
.receive = eth_rx,
|
.receive = eth_rx,
|
||||||
|
@ -832,7 +832,7 @@ axienet_stream_push(void *opaque, uint8_t *buf, size_t size, uint32_t *hdr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_xilinx_enet_info = {
|
static NetClientInfo net_xilinx_enet_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = eth_can_rx,
|
.can_receive = eth_can_rx,
|
||||||
.receive = eth_rx,
|
.receive = eth_rx,
|
||||||
|
@ -202,7 +202,7 @@ static void eth_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_xilinx_ethlite_info = {
|
static NetClientInfo net_xilinx_ethlite_info = {
|
||||||
.type = NET_CLIENT_TYPE_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = eth_can_rx,
|
.can_receive = eth_can_rx,
|
||||||
.receive = eth_rx,
|
.receive = eth_rx,
|
||||||
|
50
net.c
50
net.c
@ -239,7 +239,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
|
|||||||
VLANClientState *nc;
|
VLANClientState *nc;
|
||||||
NICState *nic;
|
NICState *nic;
|
||||||
|
|
||||||
assert(info->type == NET_CLIENT_TYPE_NIC);
|
assert(info->type == NET_CLIENT_OPTIONS_KIND_NIC);
|
||||||
assert(info->size >= sizeof(NICState));
|
assert(info->size >= sizeof(NICState));
|
||||||
|
|
||||||
nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
|
nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
|
||||||
@ -282,7 +282,7 @@ static void qemu_free_vlan_client(VLANClientState *vc)
|
|||||||
void qemu_del_vlan_client(VLANClientState *vc)
|
void qemu_del_vlan_client(VLANClientState *vc)
|
||||||
{
|
{
|
||||||
/* If there is a peer NIC, delete and cleanup client, but do not free. */
|
/* If there is a peer NIC, delete and cleanup client, but do not free. */
|
||||||
if (!vc->vlan && vc->peer && vc->peer->info->type == NET_CLIENT_TYPE_NIC) {
|
if (!vc->vlan && vc->peer && vc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
NICState *nic = DO_UPCAST(NICState, nc, vc->peer);
|
NICState *nic = DO_UPCAST(NICState, nc, vc->peer);
|
||||||
if (nic->peer_deleted) {
|
if (nic->peer_deleted) {
|
||||||
return;
|
return;
|
||||||
@ -298,7 +298,7 @@ void qemu_del_vlan_client(VLANClientState *vc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a peer NIC and peer has already been deleted, free it now. */
|
/* If this is a peer NIC and peer has already been deleted, free it now. */
|
||||||
if (!vc->vlan && vc->peer && vc->info->type == NET_CLIENT_TYPE_NIC) {
|
if (!vc->vlan && vc->peer && vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
NICState *nic = DO_UPCAST(NICState, nc, vc);
|
NICState *nic = DO_UPCAST(NICState, nc, vc);
|
||||||
if (nic->peer_deleted) {
|
if (nic->peer_deleted) {
|
||||||
qemu_free_vlan_client(vc->peer);
|
qemu_free_vlan_client(vc->peer);
|
||||||
@ -341,14 +341,14 @@ void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
|
|||||||
VLANState *vlan;
|
VLANState *vlan;
|
||||||
|
|
||||||
QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
|
QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
|
||||||
if (nc->info->type == NET_CLIENT_TYPE_NIC) {
|
if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
func(DO_UPCAST(NICState, nc, nc), opaque);
|
func(DO_UPCAST(NICState, nc, nc), opaque);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_FOREACH(vlan, &vlans, next) {
|
QTAILQ_FOREACH(vlan, &vlans, next) {
|
||||||
QTAILQ_FOREACH(nc, &vlan->clients, next) {
|
QTAILQ_FOREACH(nc, &vlan->clients, next) {
|
||||||
if (nc->info->type == NET_CLIENT_TYPE_NIC) {
|
if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
func(DO_UPCAST(NICState, nc, nc), opaque);
|
func(DO_UPCAST(NICState, nc, nc), opaque);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -664,7 +664,7 @@ VLANClientState *qemu_find_netdev(const char *id)
|
|||||||
VLANClientState *vc;
|
VLANClientState *vc;
|
||||||
|
|
||||||
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
||||||
if (vc->info->type == NET_CLIENT_TYPE_NIC)
|
if (vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC)
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(vc->name, id)) {
|
if (!strcmp(vc->name, id)) {
|
||||||
return vc;
|
return vc;
|
||||||
@ -828,15 +828,15 @@ static const struct {
|
|||||||
const char *type;
|
const char *type;
|
||||||
net_client_init_func init;
|
net_client_init_func init;
|
||||||
QemuOptDesc desc[NET_MAX_DESC];
|
QemuOptDesc desc[NET_MAX_DESC];
|
||||||
} net_client_types[NET_CLIENT_TYPE_MAX] = {
|
} net_client_types[NET_CLIENT_OPTIONS_KIND_MAX] = {
|
||||||
[NET_CLIENT_TYPE_NONE] = {
|
[NET_CLIENT_OPTIONS_KIND_NONE] = {
|
||||||
.type = "none",
|
.type = "none",
|
||||||
.desc = {
|
.desc = {
|
||||||
NET_COMMON_PARAMS_DESC,
|
NET_COMMON_PARAMS_DESC,
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[NET_CLIENT_TYPE_NIC] = {
|
[NET_CLIENT_OPTIONS_KIND_NIC] = {
|
||||||
.type = "nic",
|
.type = "nic",
|
||||||
.init = net_init_nic,
|
.init = net_init_nic,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -867,7 +867,7 @@ static const struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
[NET_CLIENT_TYPE_USER] = {
|
[NET_CLIENT_OPTIONS_KIND_USER] = {
|
||||||
.type = "user",
|
.type = "user",
|
||||||
.init = net_init_slirp,
|
.init = net_init_slirp,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -929,7 +929,7 @@ static const struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
[NET_CLIENT_TYPE_TAP] = {
|
[NET_CLIENT_OPTIONS_KIND_TAP] = {
|
||||||
.type = "tap",
|
.type = "tap",
|
||||||
.init = net_init_tap,
|
.init = net_init_tap,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -983,7 +983,7 @@ static const struct {
|
|||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[NET_CLIENT_TYPE_SOCKET] = {
|
[NET_CLIENT_OPTIONS_KIND_SOCKET] = {
|
||||||
.type = "socket",
|
.type = "socket",
|
||||||
.init = net_init_socket,
|
.init = net_init_socket,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -1017,7 +1017,7 @@ static const struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
#ifdef CONFIG_VDE
|
#ifdef CONFIG_VDE
|
||||||
[NET_CLIENT_TYPE_VDE] = {
|
[NET_CLIENT_OPTIONS_KIND_VDE] = {
|
||||||
.type = "vde",
|
.type = "vde",
|
||||||
.init = net_init_vde,
|
.init = net_init_vde,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -1043,7 +1043,7 @@ static const struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
[NET_CLIENT_TYPE_DUMP] = {
|
[NET_CLIENT_OPTIONS_KIND_DUMP] = {
|
||||||
.type = "dump",
|
.type = "dump",
|
||||||
.init = net_init_dump,
|
.init = net_init_dump,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -1061,7 +1061,7 @@ static const struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
#ifdef CONFIG_NET_BRIDGE
|
#ifdef CONFIG_NET_BRIDGE
|
||||||
[NET_CLIENT_TYPE_BRIDGE] = {
|
[NET_CLIENT_OPTIONS_KIND_BRIDGE] = {
|
||||||
.type = "bridge",
|
.type = "bridge",
|
||||||
.init = net_init_bridge,
|
.init = net_init_bridge,
|
||||||
.desc = {
|
.desc = {
|
||||||
@ -1129,7 +1129,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
|
|||||||
name = qemu_opt_get(opts, "name");
|
name = qemu_opt_get(opts, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NET_CLIENT_TYPE_MAX; i++) {
|
for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) {
|
||||||
if (net_client_types[i].type != NULL &&
|
if (net_client_types[i].type != NULL &&
|
||||||
!strcmp(net_client_types[i].type, type)) {
|
!strcmp(net_client_types[i].type, type)) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -1293,7 +1293,7 @@ void do_info_network(Monitor *mon)
|
|||||||
{
|
{
|
||||||
VLANState *vlan;
|
VLANState *vlan;
|
||||||
VLANClientState *vc, *peer;
|
VLANClientState *vc, *peer;
|
||||||
net_client_type type;
|
NetClientOptionsKind type;
|
||||||
|
|
||||||
QTAILQ_FOREACH(vlan, &vlans, next) {
|
QTAILQ_FOREACH(vlan, &vlans, next) {
|
||||||
monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
|
monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
|
||||||
@ -1307,11 +1307,11 @@ void do_info_network(Monitor *mon)
|
|||||||
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
||||||
peer = vc->peer;
|
peer = vc->peer;
|
||||||
type = vc->info->type;
|
type = vc->info->type;
|
||||||
if (!peer || type == NET_CLIENT_TYPE_NIC) {
|
if (!peer || type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
monitor_printf(mon, " ");
|
monitor_printf(mon, " ");
|
||||||
print_net_client(mon, vc);
|
print_net_client(mon, vc);
|
||||||
} /* else it's a netdev connected to a NIC, printed with the NIC */
|
} /* else it's a netdev connected to a NIC, printed with the NIC */
|
||||||
if (peer && type == NET_CLIENT_TYPE_NIC) {
|
if (peer && type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||||
monitor_printf(mon, " \\ ");
|
monitor_printf(mon, " \\ ");
|
||||||
print_net_client(mon, peer);
|
print_net_client(mon, peer);
|
||||||
}
|
}
|
||||||
@ -1399,13 +1399,13 @@ void net_check_clients(void)
|
|||||||
|
|
||||||
QTAILQ_FOREACH(vc, &vlan->clients, next) {
|
QTAILQ_FOREACH(vc, &vlan->clients, next) {
|
||||||
switch (vc->info->type) {
|
switch (vc->info->type) {
|
||||||
case NET_CLIENT_TYPE_NIC:
|
case NET_CLIENT_OPTIONS_KIND_NIC:
|
||||||
has_nic = 1;
|
has_nic = 1;
|
||||||
break;
|
break;
|
||||||
case NET_CLIENT_TYPE_USER:
|
case NET_CLIENT_OPTIONS_KIND_USER:
|
||||||
case NET_CLIENT_TYPE_TAP:
|
case NET_CLIENT_OPTIONS_KIND_TAP:
|
||||||
case NET_CLIENT_TYPE_SOCKET:
|
case NET_CLIENT_OPTIONS_KIND_SOCKET:
|
||||||
case NET_CLIENT_TYPE_VDE:
|
case NET_CLIENT_OPTIONS_KIND_VDE:
|
||||||
has_host_dev = 1;
|
has_host_dev = 1;
|
||||||
break;
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
@ -1421,7 +1421,7 @@ void net_check_clients(void)
|
|||||||
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
|
||||||
if (!vc->peer) {
|
if (!vc->peer) {
|
||||||
fprintf(stderr, "Warning: %s %s has no peer\n",
|
fprintf(stderr, "Warning: %s %s has no peer\n",
|
||||||
vc->info->type == NET_CLIENT_TYPE_NIC ? "nic" : "netdev",
|
vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? "nic" : "netdev",
|
||||||
vc->name);
|
vc->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
net.h
16
net.h
@ -7,6 +7,7 @@
|
|||||||
#include "qemu-option.h"
|
#include "qemu-option.h"
|
||||||
#include "net/queue.h"
|
#include "net/queue.h"
|
||||||
#include "vmstate.h"
|
#include "vmstate.h"
|
||||||
|
#include "qapi-types.h"
|
||||||
|
|
||||||
struct MACAddr {
|
struct MACAddr {
|
||||||
uint8_t a[6];
|
uint8_t a[6];
|
||||||
@ -29,19 +30,6 @@ typedef struct NICConf {
|
|||||||
|
|
||||||
/* VLANs support */
|
/* VLANs support */
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NET_CLIENT_TYPE_NONE,
|
|
||||||
NET_CLIENT_TYPE_NIC,
|
|
||||||
NET_CLIENT_TYPE_USER,
|
|
||||||
NET_CLIENT_TYPE_TAP,
|
|
||||||
NET_CLIENT_TYPE_SOCKET,
|
|
||||||
NET_CLIENT_TYPE_VDE,
|
|
||||||
NET_CLIENT_TYPE_DUMP,
|
|
||||||
NET_CLIENT_TYPE_BRIDGE,
|
|
||||||
|
|
||||||
NET_CLIENT_TYPE_MAX
|
|
||||||
} net_client_type;
|
|
||||||
|
|
||||||
typedef void (NetPoll)(VLANClientState *, bool enable);
|
typedef void (NetPoll)(VLANClientState *, bool enable);
|
||||||
typedef int (NetCanReceive)(VLANClientState *);
|
typedef int (NetCanReceive)(VLANClientState *);
|
||||||
typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
|
typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
|
||||||
@ -50,7 +38,7 @@ typedef void (NetCleanup) (VLANClientState *);
|
|||||||
typedef void (LinkStatusChanged)(VLANClientState *);
|
typedef void (LinkStatusChanged)(VLANClientState *);
|
||||||
|
|
||||||
typedef struct NetClientInfo {
|
typedef struct NetClientInfo {
|
||||||
net_client_type type;
|
NetClientOptionsKind type;
|
||||||
size_t size;
|
size_t size;
|
||||||
NetReceive *receive;
|
NetReceive *receive;
|
||||||
NetReceive *receive_raw;
|
NetReceive *receive_raw;
|
||||||
|
@ -93,7 +93,7 @@ static void dump_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_dump_info = {
|
static NetClientInfo net_dump_info = {
|
||||||
.type = NET_CLIENT_TYPE_DUMP,
|
.type = NET_CLIENT_OPTIONS_KIND_DUMP,
|
||||||
.size = sizeof(DumpState),
|
.size = sizeof(DumpState),
|
||||||
.receive = dump_receive,
|
.receive = dump_receive,
|
||||||
.cleanup = dump_cleanup,
|
.cleanup = dump_cleanup,
|
||||||
|
@ -129,7 +129,7 @@ static void net_slirp_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_slirp_info = {
|
static NetClientInfo net_slirp_info = {
|
||||||
.type = NET_CLIENT_TYPE_USER,
|
.type = NET_CLIENT_OPTIONS_KIND_USER,
|
||||||
.size = sizeof(SlirpState),
|
.size = sizeof(SlirpState),
|
||||||
.receive = net_slirp_receive,
|
.receive = net_slirp_receive,
|
||||||
.cleanup = net_slirp_cleanup,
|
.cleanup = net_slirp_cleanup,
|
||||||
|
@ -239,7 +239,7 @@ static void net_socket_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_dgram_socket_info = {
|
static NetClientInfo net_dgram_socket_info = {
|
||||||
.type = NET_CLIENT_TYPE_SOCKET,
|
.type = NET_CLIENT_OPTIONS_KIND_SOCKET,
|
||||||
.size = sizeof(NetSocketState),
|
.size = sizeof(NetSocketState),
|
||||||
.receive = net_socket_receive_dgram,
|
.receive = net_socket_receive_dgram,
|
||||||
.cleanup = net_socket_cleanup,
|
.cleanup = net_socket_cleanup,
|
||||||
@ -317,7 +317,7 @@ static void net_socket_connect(void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_socket_info = {
|
static NetClientInfo net_socket_info = {
|
||||||
.type = NET_CLIENT_TYPE_SOCKET,
|
.type = NET_CLIENT_OPTIONS_KIND_SOCKET,
|
||||||
.size = sizeof(NetSocketState),
|
.size = sizeof(NetSocketState),
|
||||||
.receive = net_socket_receive,
|
.receive = net_socket_receive,
|
||||||
.cleanup = net_socket_cleanup,
|
.cleanup = net_socket_cleanup,
|
||||||
|
@ -667,7 +667,7 @@ static void tap_win32_send(void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_tap_win32_info = {
|
static NetClientInfo net_tap_win32_info = {
|
||||||
.type = NET_CLIENT_TYPE_TAP,
|
.type = NET_CLIENT_OPTIONS_KIND_TAP,
|
||||||
.size = sizeof(TAPState),
|
.size = sizeof(TAPState),
|
||||||
.receive = tap_receive,
|
.receive = tap_receive,
|
||||||
.cleanup = tap_cleanup,
|
.cleanup = tap_cleanup,
|
||||||
|
16
net/tap.c
16
net/tap.c
@ -218,7 +218,7 @@ int tap_has_ufo(VLANClientState *nc)
|
|||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
|
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
|
|
||||||
return s->has_ufo;
|
return s->has_ufo;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ int tap_has_vnet_hdr(VLANClientState *nc)
|
|||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
|
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
|
|
||||||
return !!s->host_vnet_hdr_len;
|
return !!s->host_vnet_hdr_len;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ int tap_has_vnet_hdr_len(VLANClientState *nc, int len)
|
|||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
|
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
|
|
||||||
return tap_probe_vnet_hdr_len(s->fd, len);
|
return tap_probe_vnet_hdr_len(s->fd, len);
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ void tap_set_vnet_hdr_len(VLANClientState *nc, int len)
|
|||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
|
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
assert(len == sizeof(struct virtio_net_hdr_mrg_rxbuf) ||
|
assert(len == sizeof(struct virtio_net_hdr_mrg_rxbuf) ||
|
||||||
len == sizeof(struct virtio_net_hdr));
|
len == sizeof(struct virtio_net_hdr));
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ void tap_using_vnet_hdr(VLANClientState *nc, int using_vnet_hdr)
|
|||||||
|
|
||||||
using_vnet_hdr = using_vnet_hdr != 0;
|
using_vnet_hdr = using_vnet_hdr != 0;
|
||||||
|
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
assert(!!s->host_vnet_hdr_len == using_vnet_hdr);
|
assert(!!s->host_vnet_hdr_len == using_vnet_hdr);
|
||||||
|
|
||||||
s->using_vnet_hdr = using_vnet_hdr;
|
s->using_vnet_hdr = using_vnet_hdr;
|
||||||
@ -306,14 +306,14 @@ static void tap_poll(VLANClientState *nc, bool enable)
|
|||||||
int tap_get_fd(VLANClientState *nc)
|
int tap_get_fd(VLANClientState *nc)
|
||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
return s->fd;
|
return s->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fd support */
|
/* fd support */
|
||||||
|
|
||||||
static NetClientInfo net_tap_info = {
|
static NetClientInfo net_tap_info = {
|
||||||
.type = NET_CLIENT_TYPE_TAP,
|
.type = NET_CLIENT_OPTIONS_KIND_TAP,
|
||||||
.size = sizeof(TAPState),
|
.size = sizeof(TAPState),
|
||||||
.receive = tap_receive,
|
.receive = tap_receive,
|
||||||
.receive_raw = tap_receive_raw,
|
.receive_raw = tap_receive_raw,
|
||||||
@ -711,6 +711,6 @@ int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan)
|
|||||||
VHostNetState *tap_get_vhost_net(VLANClientState *nc)
|
VHostNetState *tap_get_vhost_net(VLANClientState *nc)
|
||||||
{
|
{
|
||||||
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
TAPState *s = DO_UPCAST(TAPState, nc, nc);
|
||||||
assert(nc->info->type == NET_CLIENT_TYPE_TAP);
|
assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||||
return s->vhost_net;
|
return s->vhost_net;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ static void vde_cleanup(VLANClientState *nc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_vde_info = {
|
static NetClientInfo net_vde_info = {
|
||||||
.type = NET_CLIENT_TYPE_VDE,
|
.type = NET_CLIENT_OPTIONS_KIND_VDE,
|
||||||
.size = sizeof(VDEState),
|
.size = sizeof(VDEState),
|
||||||
.receive = vde_receive,
|
.receive = vde_receive,
|
||||||
.cleanup = vde_cleanup,
|
.cleanup = vde_cleanup,
|
||||||
|
Loading…
Reference in New Issue
Block a user