From nobody Fri Jan 16 15:02:19 2026 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 4dt33v1g55z6NPCl for ; Fri, 16 Jan 2026 15:02:19 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dt33v0q5fz3MCF for ; Fri, 16 Jan 2026 15:02:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768575739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fxiPTyE8uHhpfGMT+B7U016QqpBMViwsqGRJ0TVYAE0=; b=yGjbBADGKK7a5c03/p3GLoO1hYbGziwnMxkkxZw5ZnkbuqyBkSJeUrXZxsxiuf0S78/oNN s0zezLYjYTwY/x7rGY7MTsv/pHtc6x0+MFBCGEljpvbnDfSJ8t30ZgDiBJWLUauQ/HW+qP hAhLxsGISXo15RR2DETdzobCfOGW6Xz8hBQfGGQaoDe6RXs3IOSyQjoR0IT+Wo+1F50JTP D0MA+mMkpHJxxv6o+Bc38lFCojALTP0xWBahOVfUfbwSJKnjJJ2NGx6AyQ/vqgJ9LRvuhB /kXL2828xGdtGyBbyKAjJNkIB3ZyaO50/j/sLjtKBG8Ibmbgo8ziIJWG2mO5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768575739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fxiPTyE8uHhpfGMT+B7U016QqpBMViwsqGRJ0TVYAE0=; b=qfzu/3JpbyTGOv6Rism1ATMaNc/ibwh+pqVlQdhksfS+2hAWcYJ+pbZXu9bJZs/r6p1QFu GwCHm/JFYfy092cHjJBO1Gq/r62eM5Apiv2QlZVCSGCQbkVOb5OH2OSalUYJ+OBYk2JtC0 XMRtu0MtoZ7IYT8VHYGltPXP1NkB7v9WTPmbsJpnD7NMztXByWaykgEiZqRQCS5Zd4wE3g Fe3GN5iIbpGjzkhV/RXtG7gcvDy/OoVxUrIlC0wtH3ifvBIhuccqVhm/H0yFbopxE5rgS7 npNl0HQEJH9JbQf2hXB+eEbfB8ar93QWYdqm19S6gvstLeUxbPtVkmml5n8Gog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768575739; a=rsa-sha256; cv=none; b=EZFl2DiXZlGMw5fHWWc3Wqr+/LwSlfHQzAe92Su0hs1Jcg6CnUnfXtW4rBdbP6aPsIU3hY kL/7tQsfK3cYqsDA3qzLwDOpzDSWqIRyWr550RaorioEXp660H3cHGlQ851/FOFajUJxCx UW5NVRix949vakYL2ccq96sf40KVjwQOul59gbouFK4GFo321dch7ALWpLGh8YuP7CrwMf IPxwlhXLI23yQ5beqoovL/asQCS10WoLVuDSrVXFMIFeryAT1FIbwZTzAslOjUfNR9F/lv aVfnDBM4bf3bbgwK7kvPVb7YDCLfNXugmgIuRHoVoJ5JeBGbxU4kn3owc8y7lg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dt33v0JNsz3wD for ; Fri, 16 Jan 2026 15:02:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 22a15 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 16 Jan 2026 15:02:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Hans Rosenfeld From: Joseph Mingrone Subject: git: e2d7bec6bc5a - main - bhyve: Want walk_config_nodes 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2d7bec6bc5a124091859ad134bc9cfc2a8b4688 Auto-Submitted: auto-generated Date: Fri, 16 Jan 2026 15:02:19 +0000 Message-Id: <696a52fb.22a15.1c168b7b@gitrepo.freebsd.org> The branch main has been updated by jrm: URL: https://cgit.FreeBSD.org/src/commit/?id=e2d7bec6bc5a124091859ad134bc9cfc2a8b4688 commit e2d7bec6bc5a124091859ad134bc9cfc2a8b4688 Author: Hans Rosenfeld AuthorDate: 2026-01-16 14:43:44 +0000 Commit: Joseph Mingrone CommitDate: 2026-01-16 14:48:34 +0000 bhyve: Want walk_config_nodes Add a function to all nodes under a config option node. This allows parsing an arbitrary number of similarly structured configuration options in a config option group. Reviewed by: corvink, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51551 --- usr.sbin/bhyve/config.c | 49 +++++++++++++++++++++++++++++++++---------------- usr.sbin/bhyve/config.h | 9 +++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/usr.sbin/bhyve/config.c b/usr.sbin/bhyve/config.c index cc9311624e5e..9f7e3061979a 100644 --- a/usr.sbin/bhyve/config.c +++ b/usr.sbin/bhyve/config.c @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2021 John H. Baldwin + * Copyright 2026 Hans Rosenfeld * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -434,31 +435,47 @@ set_config_bool_node(nvlist_t *parent, const char *name, bool value) set_config_value_node(parent, name, value ? "true" : "false"); } -static void -dump_tree(const char *prefix, const nvlist_t *nvl) +int +walk_config_nodes(const char *prefix, const nvlist_t *parent, void *arg, + int (*cb)(const char *, const nvlist_t *, const char *, int, void *)) { + void *cookie = NULL; const char *name; - void *cookie; int type; - cookie = NULL; - while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) { - if (type == NV_TYPE_NVLIST) { - char *new_prefix; + while ((name = nvlist_next(parent, &type, &cookie)) != NULL) { + int ret; - asprintf(&new_prefix, "%s%s.", prefix, name); - dump_tree(new_prefix, nvlist_get_nvlist(nvl, name)); - free(new_prefix); - } else { - assert(type == NV_TYPE_STRING); - printf("%s%s=%s\n", prefix, name, - nvlist_get_string(nvl, name)); - } + ret = cb(prefix, parent, name, type, arg); + if (ret != 0) + return (ret); + } + + return (0); +} + +static int +dump_node_cb(const char *prefix, const nvlist_t *parent, const char *name, + int type, void *arg) +{ + if (type == NV_TYPE_NVLIST) { + char *new_prefix; + int ret; + + asprintf(&new_prefix, "%s%s.", prefix, name); + ret = walk_config_nodes(new_prefix, + nvlist_get_nvlist(parent, name), arg, dump_node_cb); + free(new_prefix); + return (ret); } + + assert(type == NV_TYPE_STRING); + printf("%s%s=%s\n", prefix, name, nvlist_get_string(parent, name)); + return (0); } void dump_config(void) { - dump_tree("", config_root); + (void)walk_config_nodes("", config_root, NULL, dump_node_cb); } diff --git a/usr.sbin/bhyve/config.h b/usr.sbin/bhyve/config.h index 35882e65ace7..acdd621af5ee 100644 --- a/usr.sbin/bhyve/config.h +++ b/usr.sbin/bhyve/config.h @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2021 John H. Baldwin + * Copyright 2026 Hans Rosenfeld * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,6 +46,14 @@ * OIDs. */ +/* + * Walk the nodes under a parent nvlist. For each node found, call the given + * callback function passing the current prefix, nvlist, node name and type, + * and the given argument. + */ +int walk_config_nodes(const char *, const nvlist_t *, void *, + int (*cb)(const char *, const nvlist_t *, const char *, int, void *)); + /* * Fetches the value of a configuration variable. If the "raw" value * contains references to other configuration variables, this function