net: Export valid host network devices list

Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Hani Benhabiles 2014-05-27 23:39:33 +01:00 committed by Luiz Capitulino
parent c68a0409b3
commit 84007e8181
2 changed files with 21 additions and 14 deletions

View File

@ -177,6 +177,7 @@ struct NICInfo {
extern int nb_nics;
extern NICInfo nd_table[MAX_NICS];
extern int default_net;
extern const char *host_net_devices[];
/* from net.c */
extern const char *legacy_tftp_prefix;

View File

@ -49,6 +49,22 @@
static QTAILQ_HEAD(, NetClientState) net_clients;
const char *host_net_devices[] = {
"tap",
"socket",
"dump",
#ifdef CONFIG_NET_BRIDGE
"bridge",
#endif
#ifdef CONFIG_SLIRP
"user",
#endif
#ifdef CONFIG_VDE
"vde",
#endif
NULL,
};
int default_net = 1;
/***********************************************************/
@ -897,21 +913,11 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
static int net_host_check_device(const char *device)
{
int i;
const char *valid_param_list[] = { "tap", "socket", "dump"
#ifdef CONFIG_NET_BRIDGE
, "bridge"
#endif
#ifdef CONFIG_SLIRP
,"user"
#endif
#ifdef CONFIG_VDE
,"vde"
#endif
};
for (i = 0; i < ARRAY_SIZE(valid_param_list); i++) {
if (!strncmp(valid_param_list[i], device,
strlen(valid_param_list[i])))
for (i = 0; host_net_devices[i]; i++) {
if (!strncmp(host_net_devices[i], device,
strlen(host_net_devices[i]))) {
return 1;
}
}
return 0;