mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
net: Refactor net_client_types
Position entries of net_client_types according to the corresponding values of NET_CLIENT_TYPE_*. The array size is now defined by NET_CLIENT_TYPE_MAX. This will allow to obtain entries based on type value in later patches. At this chance rename NET_CLIENT_TYPE_SLIRP to NET_CLIENT_TYPE_USER for the sake of consistency. CC: Markus Armbruster <armbru@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
19061e63c0
commit
6f7b3b1be2
3 changed files with 23 additions and 15 deletions
30
net.c
30
net.c
|
@ -830,14 +830,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_types[NET_CLIENT_TYPE_MAX] = {
|
||||||
{
|
[NET_CLIENT_TYPE_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] = {
|
||||||
.type = "nic",
|
.type = "nic",
|
||||||
.init = net_init_nic,
|
.init = net_init_nic,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -866,8 +867,9 @@ static const struct {
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
|
},
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
}, {
|
[NET_CLIENT_TYPE_USER] = {
|
||||||
.type = "user",
|
.type = "user",
|
||||||
.init = net_init_slirp,
|
.init = net_init_slirp,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -927,8 +929,9 @@ static const struct {
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
}, {
|
[NET_CLIENT_TYPE_TAP] = {
|
||||||
.type = "tap",
|
.type = "tap",
|
||||||
.init = net_init_tap,
|
.init = net_init_tap,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -975,7 +978,8 @@ static const struct {
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
[NET_CLIENT_TYPE_SOCKET] = {
|
||||||
.type = "socket",
|
.type = "socket",
|
||||||
.init = net_init_socket,
|
.init = net_init_socket,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -1003,8 +1007,9 @@ static const struct {
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
|
},
|
||||||
#ifdef CONFIG_VDE
|
#ifdef CONFIG_VDE
|
||||||
}, {
|
[NET_CLIENT_TYPE_VDE] = {
|
||||||
.type = "vde",
|
.type = "vde",
|
||||||
.init = net_init_vde,
|
.init = net_init_vde,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -1028,8 +1033,9 @@ static const struct {
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
}, {
|
[NET_CLIENT_TYPE_DUMP] = {
|
||||||
.type = "dump",
|
.type = "dump",
|
||||||
.init = net_init_dump,
|
.init = net_init_dump,
|
||||||
.desc = {
|
.desc = {
|
||||||
|
@ -1046,7 +1052,6 @@ static const struct {
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ /* end of list */ }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
|
int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
|
||||||
|
@ -1094,8 +1099,9 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
|
||||||
name = qemu_opt_get(opts, "name");
|
name = qemu_opt_get(opts, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; net_client_types[i].type != NULL; i++) {
|
for (i = 0; i < NET_CLIENT_TYPE_MAX; i++) {
|
||||||
if (!strcmp(net_client_types[i].type, type)) {
|
if (net_client_types[i].type != NULL &&
|
||||||
|
!strcmp(net_client_types[i].type, type)) {
|
||||||
VLANState *vlan = NULL;
|
VLANState *vlan = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1330,7 +1336,7 @@ void net_check_clients(void)
|
||||||
case NET_CLIENT_TYPE_NIC:
|
case NET_CLIENT_TYPE_NIC:
|
||||||
has_nic = 1;
|
has_nic = 1;
|
||||||
break;
|
break;
|
||||||
case NET_CLIENT_TYPE_SLIRP:
|
case NET_CLIENT_TYPE_USER:
|
||||||
case NET_CLIENT_TYPE_TAP:
|
case NET_CLIENT_TYPE_TAP:
|
||||||
case NET_CLIENT_TYPE_SOCKET:
|
case NET_CLIENT_TYPE_SOCKET:
|
||||||
case NET_CLIENT_TYPE_VDE:
|
case NET_CLIENT_TYPE_VDE:
|
||||||
|
|
6
net.h
6
net.h
|
@ -31,11 +31,13 @@ typedef struct NICConf {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NET_CLIENT_TYPE_NONE,
|
NET_CLIENT_TYPE_NONE,
|
||||||
NET_CLIENT_TYPE_NIC,
|
NET_CLIENT_TYPE_NIC,
|
||||||
NET_CLIENT_TYPE_SLIRP,
|
NET_CLIENT_TYPE_USER,
|
||||||
NET_CLIENT_TYPE_TAP,
|
NET_CLIENT_TYPE_TAP,
|
||||||
NET_CLIENT_TYPE_SOCKET,
|
NET_CLIENT_TYPE_SOCKET,
|
||||||
NET_CLIENT_TYPE_VDE,
|
NET_CLIENT_TYPE_VDE,
|
||||||
NET_CLIENT_TYPE_DUMP
|
NET_CLIENT_TYPE_DUMP,
|
||||||
|
|
||||||
|
NET_CLIENT_TYPE_MAX
|
||||||
} net_client_type;
|
} net_client_type;
|
||||||
|
|
||||||
typedef void (NetPoll)(VLANClientState *, bool enable);
|
typedef void (NetPoll)(VLANClientState *, bool enable);
|
||||||
|
|
|
@ -128,7 +128,7 @@ static void net_slirp_cleanup(VLANClientState *nc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static NetClientInfo net_slirp_info = {
|
static NetClientInfo net_slirp_info = {
|
||||||
.type = NET_CLIENT_TYPE_SLIRP,
|
.type = NET_CLIENT_TYPE_USER,
|
||||||
.size = sizeof(SlirpState),
|
.size = sizeof(SlirpState),
|
||||||
.receive = net_slirp_receive,
|
.receive = net_slirp_receive,
|
||||||
.cleanup = net_slirp_cleanup,
|
.cleanup = net_slirp_cleanup,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue