Re: RFC: Add required_klds metadata to Kyua

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 07 Nov 2024 15:43:49 UTC
On 7 Nov 2024, at 16:16, Alan Somers wrote:
> I too like the idea of Project A with required_klds or required_kmods.
> But how would you handle situations where a user customizes their
> kernel config to build some feature that's usually a module directly
> into the kernel?  I would think that would break any test using
> required_klds.
>
That’s actually fine if we use `kldstat -m` or modfind(). It’ll 
still find a “module” even when it’s built into the kernel.

For example, pfsense builds pf into the kernel:

	[24.11-BETA][root@pfSense.jupiter.sigsegv.be]/root: kldstat
	Id Refs Address                Size Name
	 1   19 0xffff000000000000  28e4d90 kernel
	 2    1 0xffff0000028e5000   46e278 zfs.ko
	 3    1 0xffff000002d54000    3e258 opensolaris.ko
	 4    1 0xffff0000b1c00000    27000 safexcel.ko
	 5    1 0xffff0000b1c27000    26000 cryptodev.ko
	[24.11-BETA][root@pfSense.jupiter.sigsegv.be]/root: kldstat -m pf
	Id  Refs Name
	440    1 pf

Or when it actually is a module:

	freebsd_current_zfs# kldstat
	Id Refs Address                Size Name
	 1   48 0xffffffff80200000  1f75b10 kernel
	 2    1 0xffffffff82176000     6320 filemon.ko
	 3    1 0xffffffff8217d000   78fdf8 zfs.ko
	 4    1 0xffffffff83010000     2a68 mac_ntpd.ko
	 5    3 0xffffffff83013000    5adc0 pf.ko
	 6    1 0xffffffff8306e000     9688 pfsync.ko
	 7    1 0xffffffff83078000     2260 pflog.ko
	 8    1 0xffffffff8307b000    128a0 dummynet.ko
	 9    1 0xffffffff8308e000     9890 carp.ko
	10    1 0xffffffff83098000    18148 ipsec.ko
	11    1 0xffffffff830b1000    7bf98 sctp.ko
	12    1 0xffffffff8312d000     2568 ipdivert.ko
	13    1 0xffffffff83130000     88d8 if_bridge.ko
	14    1 0xffffffff83139000     5120 bridgestp.ko
	15    1 0xffffffff8313f000     52a4 if_epair.ko
	freebsd_current_zfs# kldstat -m pf
	Id  Refs Name
	506    1 pf
	freebsd_current_zfs# kldunload pfsync                                   
                                                                                                                                                 	freebsd_current_zfs# 
kldunload pflog
	freebsd_current_zfs# kldunload pf
	freebsd_current_zfs# kldstat -m pf
	kldstat: can't find module pf: No such file or directory

—
Kristof