Changeset View
Standalone View
usr.sbin/bhyve/config.h
| /*- | /*- | |||||||||||||
| * SPDX-License-Identifier: BSD-2-Clause | * SPDX-License-Identifier: BSD-2-Clause | |||||||||||||
| * | * | |||||||||||||
| * Copyright (c) 2021 John H. Baldwin <jhb@FreeBSD.org> | * Copyright (c) 2021 John H. Baldwin <jhb@FreeBSD.org> | |||||||||||||
| * Copyright 2026 Hans Rosenfeld | ||||||||||||||
| * | * | |||||||||||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | |||||||||||||
| * modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | |||||||||||||
| * are met: | * are met: | |||||||||||||
| * 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | |||||||||||||
| * notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | |||||||||||||
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | |||||||||||||
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | |||||||||||||
| Show All 26 Lines | ||||||||||||||
| * case, the name must be the full path of the configuration | * case, the name must be the full path of the configuration | |||||||||||||
| * variable. The % character can be escaped with a preceding \ to | * variable. The % character can be escaped with a preceding \ to | |||||||||||||
| * avoid expansion. Any \ characters must be escaped. | * avoid expansion. Any \ characters must be escaped. | |||||||||||||
| * | * | |||||||||||||
| * Configuration variables are stored in a tree. The full path of a | * Configuration variables are stored in a tree. The full path of a | |||||||||||||
| * variable is specified as a dot-separated name similar to sysctl(8) | * variable is specified as a dot-separated name similar to sysctl(8) | |||||||||||||
| * OIDs. | * 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, | ||||||||||||||
markj: This doesn't actually pass the current prefix though. Each consumer of this function has to… | ||||||||||||||
Done Inline ActionsWell, it really only passes the current prefix to the callback. If the callback wants to call walk_config_nodes() recursively, it needs to create a new prefix from the original prefix if it wants that. Or did I miss anything? rosenfeld_grumpf.hope-2000.org: Well, it really only passes the current prefix to the callback. If the callback wants to call… | ||||||||||||||
Not Done Inline ActionsRight, so it's effectively just a second arg parameter since it's up to the callback to do something useful with it. It just seems redundant: why not have dump_config() pass the prefix string as the callback arg instead of having a separate parameter for it? markj: Right, so it's effectively just a second `arg` parameter since it's up to the callback to do… | ||||||||||||||
Done Inline ActionsI can see why it may seem that way. dump_config() uses prefix it that way, and it has no need for arg. In the virtio-scsi multi-target change, prefix isn't used at all, but arg is used to pass the virtio-scsi softc around. But that's really just an implementation detail of these two changesets. While arg is intended to be used to pass anything to the callback, prefix is really supposed to pass a prefix string of config options if the callbacks need it, as is done by dump_config(). Another change I did as an experiment reworked the PCI initialization to use walk_config_nodes() to recursively initialize the PCI devices that were defined. This used both, arg to pass the device config nvlist and prefix to keep track the bus/slot/func currently being worked on. (I didn't post this change for review as it turned out it didn't really simplify things.) Of course, it's always possible to define a special struct for such cases and pass that through arg, but it seemed nicer with this interface as it is. rosenfeld_grumpf.hope-2000.org: I can see why it may seem that way. dump_config() uses `prefix` it that way, and it has no need… | ||||||||||||||
| * 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 *)); | ||||||||||||||
Not Done Inline Actions
I personally prefer adding names to parameters in header files. However, it's just my preference, so feel free to ignore this comment. corvink: I personally prefer adding names to parameters in header files. However, it's just my… | ||||||||||||||
| /* | /* | |||||||||||||
| * Fetches the value of a configuration variable. If the "raw" value | * Fetches the value of a configuration variable. If the "raw" value | |||||||||||||
| * contains references to other configuration variables, this function | * contains references to other configuration variables, this function | |||||||||||||
| * expands those references and returns a pointer to the parsed | * expands those references and returns a pointer to the parsed | |||||||||||||
| * string. The string's storage is only stable until the next call to | * string. The string's storage is only stable until the next call to | |||||||||||||
| * this function. | * this function. | |||||||||||||
| * | * | |||||||||||||
| ▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines | ||||||||||||||
This doesn't actually pass the current prefix though. Each consumer of this function has to build up the config node names itself, if it wants that.