Page MenuHomeFreeBSD

bhyve: want walk_config_nodes
AcceptedPublic

Authored by rosenfeld_grumpf.hope-2000.org on Jul 26 2025, 11:15 AM.
Tags
None
Referenced Files
F133316618: D51551.id159178.diff
Fri, Oct 24, 9:32 PM
Unknown Object (File)
Sat, Oct 18, 7:31 PM
Unknown Object (File)
Fri, Oct 17, 3:02 PM
Unknown Object (File)
Mon, Oct 13, 12:10 PM
Unknown Object (File)
Thu, Oct 9, 4:28 PM
Unknown Object (File)
Thu, Oct 9, 4:28 PM
Unknown Object (File)
Thu, Oct 9, 2:52 PM
Unknown Object (File)
Wed, Oct 1, 4:46 AM

Details

Reviewers
corvink
markj
Group Reviewers
bhyve
Summary

Add a function to recursively walk a subtree of config options. While
here, reimplement dump_config() using this new function.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67929
Build 64812: arc lint + arc unit

Event Timeline

corvink added a subscriber: corvink.

Could you please describe a use case in the commit message?

This revision is now accepted and ready to land.Jul 28 2025, 9:06 AM

Make walk_config_nodes non-recursive, leaving recursive processing to
the callback function if needed. Also, stop walking if the callback
returns a non-zero value, returning that value to the caller.

This revision now requires review to proceed.Mon, Oct 20, 7:37 AM
markj added inline comments.
usr.sbin/bhyve/config.c
479
usr.sbin/bhyve/config.h
50

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.

rosenfeld_grumpf.hope-2000.org added inline comments.
usr.sbin/bhyve/config.h
50

Well, 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?

usr.sbin/bhyve/config.h
50

Right, 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?

usr.sbin/bhyve/config.h
50

I 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.

usr.sbin/bhyve/config.c
439

Same here, I prefer adding names to the parameter but feel free to ignore my comment.

usr.sbin/bhyve/config.h
53–54

I personally prefer adding names to parameters in header files. However, it's just my preference, so feel free to ignore this comment.

This revision is now accepted and ready to land.Tue, Oct 21, 1:57 PM