Date: Thu, 10 Nov 2022 22:04:57 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: c0ca5055f323 - stable/13 - bhyve virtio-net: Allow backend type to be explicitly specified. Message-ID: <202211102204.2AAM4vwO043374@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c0ca5055f3235fafb3543649acc4e5da0a6b1421 commit c0ca5055f3235fafb3543649acc4e5da0a6b1421 Author: Yan Ka Chiu <nyan@myuji.xyz> AuthorDate: 2022-06-30 17:29:45 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-11-10 21:51:52 +0000 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 (cherry picked from commit b9c3e544c48e76dd01aa32e9b1f5cd4c1ad8532c) --- usr.sbin/bhyve/net_backends.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c index 22d489db0793..16a3d831aaa3 100644 --- a/usr.sbin/bhyve/net_backends.c +++ b/usr.sbin/bhyve/net_backends.c @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211102204.2AAM4vwO043374>