From nobody Thu Nov 10 22:04:57 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N7bVL1fWHz4d7Lb; Thu, 10 Nov 2022 22:04:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N7bVL1Dpvz4Lnk; Thu, 10 Nov 2022 22:04:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668117898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/N6OTXpaN6QYd1AboR0MfKiM/0utkAzPtDOSkMBJpEc=; b=j6odGU0kiVZ1y8TEMsxnhvH2165h9f1+RfZ16HNwVu/7xOBazXgb+Jg7guGcsgTdPd/RI7 N6BCJ+vbWJManZVdETJqzXNMVESWHaVjEl23lEVu1zXyDwEdb2HQvDwzb9HR8AN4OcXNy2 t06XkDYborqGlvn82mxcfgh7DyPV1O52bipMZeKpw+EQ4kPzZLdseGmXPip9iLh1OfgKZc kExe6cqhKy4OlxsaZvMcIhX6TBE3PQsXBy955btSxGov/1/yEB1w/yuJDmzLg0yEW402VX 95W+hANFQuckyc6n3U0CpLSWneYo+Uo7zAZ35EYMrKBMpsEe9RkZx/r5vIAXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668117898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/N6OTXpaN6QYd1AboR0MfKiM/0utkAzPtDOSkMBJpEc=; b=rYvtrNcFpAtN2dP6UcElf/WeZbkSLmAiBJNNoyo3yhihH0EKEhq7yfDQkJYu5BL80SCKNq SHzSbFS9+oHoBIUVqbTL4Zy9Kc+MbsJrOVAAvAs8354XsmP1bwwMhahr8uL+sWtHJSEgOk 9jqZlEEoLWRo9QsiXoknx9FVg0kGOAzgFQYxhLT7Y4FnL2B2hc35NwqCtJ1VR0/i6JKq2X YkoikDvHl0q/Q1XRjnsm4UIy2ObnU5fZuT1uXMzbwXMTZk5n1nYiqw1eq2QTCQDASc1ENU RRCxW/aKBmWxo4o+UdgFCzHm3IywuLA8LJspsm9ZHNFRiWuPFeA3aJH6fhZLSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668117898; a=rsa-sha256; cv=none; b=ucccuKUbTOkiEhe/AzCOlZh4nFifx0G/AbghiduV7CThx/+/R95O6zlb1cHO+eFxoIrKbK kbnV++L7l35DWEx8Xv/LOryVKtNx+BQywGK+KiXXXRWuJGJ+Zvdiu2kpWyVOlr13gegqYJ GKL4ya+y86RuYrDbsyunKk5+D00uWLWnW4BorTaQi6oaktNMPFUJQpqazQlD/c3QTLsMzz NySy5XLQLEfvCOyfxsSQI1P2hSEaumUsTb8yzxWqZYCofiWbIeRN0XTuUvLFsg5bL1fEPX yvzxxBb3GFUoN759GEDRHcmMJhHfJVrKpTIm2JrkO5HzEAVoAJ3gu31hH6iOog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N7bVL0K5dzHrg; Thu, 10 Nov 2022 22:04:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AAM4v2f043375; Thu, 10 Nov 2022 22:04:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AAM4vwO043374; Thu, 10 Nov 2022 22:04:57 GMT (envelope-from git) Date: Thu, 10 Nov 2022 22:04:57 GMT Message-Id: <202211102204.2AAM4vwO043374@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: c0ca5055f323 - stable/13 - bhyve virtio-net: Allow backend type to be explicitly specified. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c0ca5055f3235fafb3543649acc4e5da0a6b1421 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c0ca5055f3235fafb3543649acc4e5da0a6b1421 commit c0ca5055f3235fafb3543649acc4e5da0a6b1421 Author: Yan Ka Chiu AuthorDate: 2022-06-30 17:29:45 +0000 Commit: John Baldwin 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);