From nobody Thu Jun 30 17:30:48 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 7E8AC871245; Thu, 30 Jun 2022 17:30:48 +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 4LYljN3Bsbz4Sqb; Thu, 30 Jun 2022 17:30:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656610248; 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=BZckUbkIPWNgoA7Mvbgs+W0TVndOt4WUhGq4UwqNuLE=; b=X51MDi2SDH+q5FiNfYYYXYV7cQFw4G6NbKYQ2/z0aEqjF0was6NulM9jyupZJl37C6P+Lv 9zxetkTJ52YtaAXaf30sgj7Cle0PZzPmaebV1Sc1NhA438QLv6l3CBwsfMqdkWssmC5+Yq 1lAKoAfsVwTCvYTME0UOft3nVJ1JoQU7KdqV6paWC2aKTFdQdVw5jg5covajjHyteczbpU 7dhWZMuzKLN/K+Qax/47p95o2rccr2KLH84dfCUFhSsU9ZGI/KCQsVw+BfwmNNVpgnBDnC ZSEBOynMNBhLQbgvBhLMAwZBCIM5qJ/q5wZV1/nrpCI5HrqbIR4V+yi00eTPbg== 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 4DA3626EE; Thu, 30 Jun 2022 17:30:48 +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 25UHUmXB018702; Thu, 30 Jun 2022 17:30:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25UHUm5V018701; Thu, 30 Jun 2022 17:30:48 GMT (envelope-from git) Date: Thu, 30 Jun 2022 17:30:48 GMT Message-Id: <202206301730.25UHUm5V018701@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: b9c3e544c48e - main - 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/main X-Git-Reftype: branch X-Git-Commit: b9c3e544c48e76dd01aa32e9b1f5cd4c1ad8532c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656610248; 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=BZckUbkIPWNgoA7Mvbgs+W0TVndOt4WUhGq4UwqNuLE=; b=B0pdVG7rbDa31JbADmNQ9t4widoEG1GMJ4GGxVCY4Tvt8o1ZEZ4BTp4zoefFKi8DPUYnw+ KAlpe6FY32iZhJ7khoekGnr9SUtc+DeveF4EDrvr6W8OCRX3xo9Vqwg5TYgig3Vjd14hgd lb8O7osKKBLilP3rpt3pu1LaCXMTxCbRxzJEujPQm6anE2gZ7pgZ7CmbIOcokpts2A8eHv CFRXbCQhW8qbHN6yRMZaS9m/ChKEa6hIN7KNKsgnv7alTutbz0ldcptm46R19OKrJG0eBl 9F0YJLvlysTPSkQjrr8WjKtzYw7I51xcHA+0iw+UR2tS6bcyctM65QAMMPL8Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656610248; a=rsa-sha256; cv=none; b=UckF/X7eMA8JLBl+ODU+L/Wg/xXscMbGhF711xdFOT+eF/V43IU+6lsNnYmp/UyKaQ2EIf 1ATv1lkzO4uslhOF8d+d6Px4pggWsfgyKgRkAiuyvK8ss1WV1VQhknMW8LzLfOEQbRL4xE c328qeS9oelSSDKYniwjuP9j/vpSVBnWzxfUclmk2wp+Zs5MD4LZg4p7naPu5RcZ2r4xLo 7axJ3y9ug2PxVOKpVMS67smtpjdWxLxlKJRjDwVaxZT4Eh1mL+zDJgm0UpgLO6qVX8Uxhn OkcrwooYeAUX2OILSP02MhYyPmBigVl5NC8sn5DyS3OFGleid1oZH3fVw9lZ1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b9c3e544c48e76dd01aa32e9b1f5cd4c1ad8532c commit b9c3e544c48e76dd01aa32e9b1f5cd4c1ad8532c Author: Yan Ka Chiu AuthorDate: 2022-06-30 17:29:45 +0000 Commit: John Baldwin CommitDate: 2022-06-30 17:29:45 +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 --- 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 ca4c96b10239..9fcc33216bad 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);