lua: add modules.loaded hook

This may be used for the local module to hook in and load any additional
modules that it wants, since it can't modify the modules table internal to
config. We may consider adding API to do so at a later time, but I suspect
it will be more complicated to use with little return.

status is captured but ignored for the purpose of loading the hook. status
will be false if *any* module failed to load, but we typically don't let
that halt the boot so there's no reason to let it halt hooks. Some vendors
or setups may have expected fails that would be actively thwarted by
checking it.

We may, at a later date, consider adding an API for letting non-config
modules check which modules have successfully (or not) loaded in case an
unexpected failure *should* halt whatever they are doing.

MFC after:	3 days
This commit is contained in:
Kyle Evans 2020-01-25 03:52:16 +00:00
parent 59ba5b1dc2
commit 0db2ca0c31

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
local loaded, status
if xen_kernel ~= nil then
print(MSG_XENKERNLOADING)
@ -640,9 +640,12 @@ function config.loadelf()
end
print(MSG_MODLOADING)
return loadModule(modules, not config.verbose)
status = loadModule(modules, not config.verbose)
hook.runAll("modules.loaded")
return status
end
hook.registerType("config.loaded")
hook.registerType("config.reloaded")
hook.registerType("modules.loaded")
return config