bhyve virtio-net: Allow backend type to be explicitly specified.
Surrently virtio-net uses the prefix of the backing interface to choose the backend. This patch adds an additional option "type" to choose the backend type explicitly. This allows greater flexibility for end users to manage bhyve specific resources (such as by naming the tap interfaces to more descriptive names). The option "type" is optional. When it is not presented, the backend is derived from the name of the backend interface. For example, the line `-s 3,virtio-net,bsdvm0,type=tap` will create a virtio-net device for the guest using the tap interface "bsdvm0". Adding a new "type" option preserves the current legacy format in which the first value after virtio-net names an instance of a backend. Note that tap interfaces not following the pattern "tap*" will not be created on demand via devfs cloning but must be created explicitly. Reviewed by: vmaffione, jhb Differential Revision: https://reviews.freebsd.org/D35143
This commit is contained in:
parent
5afcca138f
commit
b9c3e544c4
@ -980,7 +980,7 @@ netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb,
|
||||
void *param)
|
||||
{
|
||||
struct net_backend **pbe, *nbe, *tbe = NULL;
|
||||
const char *value;
|
||||
const char *value, *type;
|
||||
char *devname;
|
||||
int err;
|
||||
|
||||
@ -990,12 +990,20 @@ netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb,
|
||||
}
|
||||
devname = strdup(value);
|
||||
|
||||
/*
|
||||
* Use the type given by configuration if exists; otherwise
|
||||
* use the prefix of the backend as the type.
|
||||
*/
|
||||
type = get_config_value_node(nvl, "type");
|
||||
if (type == NULL)
|
||||
type = devname;
|
||||
|
||||
/*
|
||||
* Find the network backend that matches the user-provided
|
||||
* device name. net_backend_set is built using a linker set.
|
||||
*/
|
||||
SET_FOREACH(pbe, net_backend_set) {
|
||||
if (strncmp(devname, (*pbe)->prefix,
|
||||
if (strncmp(type, (*pbe)->prefix,
|
||||
strlen((*pbe)->prefix)) == 0) {
|
||||
tbe = *pbe;
|
||||
assert(tbe->init != NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user