Hi, on VMs without any sound device /etc/rc.d/virtual_oss triggers sysctl(8) to output the error message "unknown oid 'hw.snd.default_unit'" on the console at system startup or shutdown. The rc.conf variable virtual_oss_enable has its default value of "NO" from /etc/defaults/rc.conf. Without much changing of virtual_oss script a simple solution would be to redirect stderr to /dev/null while executing sysctl(8). Regards Ralf
I suspect your proposal will also fail, but because virtual_oss will try to use "/dev/dsp" with the -f option (see script), which won't exist if you have no sound device available at that time. In fact, the commit that introduced the sysctl command [1] in fact indirectly fixes what I just described. If you run a VM without sound devices, and the virtual_oss rc service is disabled by default, how do you end up running into this error in the first place? [1] https://cgit.freebsd.org/src/commit/?id=06b466526a7fc35cc6fc5bf6f6269e7f3a0a7aea
(In reply to Christos Margiolis from comment #1) > If you run a VM without sound devices, and the virtual_oss rc service is > disabled by default, how do you end up running into this error in the first > place? Because the default_unit variable gets its value from sysctl set up before the value of virtual_oss_enable is evaluated. So $(sysctl -n hw.snd.default_unit) is called regardless of virtual_oss_enable's value. Please see the excerpt from the output of sh -xv /etc/rc.d/virtual_oss start on such a VM: ... configs= + configs='' pidpath="/var/run/${name}" + pidpath=/var/run/virtual_oss default_unit=$(sysctl -n hw.snd.default_unit) + sysctl -n hw.snd.default_unit sysctl: unknown oid 'hw.snd.default_unit' + default_unit='' virtual_oss_default_args="\ -S \ -C 2 \ -c 2 \ -r 48000 \ -b 24 \ -s 8ms \ -i 8 \ -f /dev/dsp${default_unit} \ -d dsp \ -t vdsp.ctl" + virtual_oss_default_args=$'\t-S \t-C 2 \t-c 2 \t-r 48000 \t-b 24 \t-s 8ms \t-i 8 \t-f /dev/dsp \t-d dsp \t-t vdsp.ctl' # Set to NO by default. Set it to "YES" to enable virtual_oss. : "${virtual_oss_enable:="NO"}" + : NO ...
(In reply to rz-rpi03 from comment #2) Is the issue addressed if you redirect sysctl's stderr to /dev/null as you said, or are there other problems with this approach?
(In reply to Christos Margiolis from comment #3) Just changed the rc.d script as suggested on a spare VM and rebooted. I did not notice any negative effects on shutdown and boot. So I think there are no other problems with this approach.
(In reply to rz-rpi03 from comment #4) Feel free to attach the patch and I'll commit it right away. Thanks.
Created attachment 268559 [details] Verified proposed patch. Simple fix as suggested.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e85f221def717660c9daf4c0616dfb9cdfb75827 commit e85f221def717660c9daf4c0616dfb9cdfb75827 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2026-03-06 12:27:03 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2026-03-06 12:27:03 +0000 rc: virtual_oss: Silence potential hw.snd.default_unit error PR: 293582 Sponsored by: The FreeBSD Foundation MFC after: 1 week libexec/rc/rc.d/virtual_oss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=63888350d583e370814abb5c078244cd8ddf8eeb commit 63888350d583e370814abb5c078244cd8ddf8eeb Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2026-03-06 12:27:03 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2026-03-13 11:49:23 +0000 rc: virtual_oss: Silence potential hw.snd.default_unit error PR: 293582 Sponsored by: The FreeBSD Foundation MFC after: 1 week (cherry picked from commit e85f221def717660c9daf4c0616dfb9cdfb75827) libexec/rc/rc.d/virtual_oss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)