loader: Add a "kernel.loaded" hook

This hook can be useful, for example to run a local function to choose
different modules to load when a user has picked a different kernel
from the menu.

Reviewed by:	kevans
Approved by:	mav (mentor)
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D24115
This commit is contained in:
Ryan Moeller 2020-03-18 16:21:11 +00:00
parent 6ac25cd4ac
commit 79c20f2260

View File

@ -623,7 +623,7 @@ end
function config.loadelf()
local xen_kernel = loader.getenv('xen_kernel')
local kernel = config.kernel_selected or config.kernel_loaded
local loaded, status
local status
if xen_kernel ~= nil then
print(MSG_XENKERNLOADING)
@ -633,11 +633,10 @@ function config.loadelf()
end
end
print(MSG_KERNLOADING)
loaded = config.loadKernel(kernel)
if not loaded then
if not config.loadKernel(kernel) then
return false
end
hook.runAll("kernel.loaded")
print(MSG_MODLOADING)
status = loadModule(modules, not config.verbose)