Use kmod library to load modules in init script #2034
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows for loading kernel modules in the init binary that is run during UVM boot. This is necessary for running certain distros of linux since many builtin modules have been moved out into their own .ko files. We use the same library, libkmod, that is used by programs like systemd and dracut to accomplish this.
We could alternatively manually call the __NR_finit_module syscall with each .ko file that we find to load the modules. However, some modules have dependencies on other modules being loaded first, which would require us to manually track the dependency graph of modules. When you run
depmod
in a system, a series of files such as modules.dep are created under /lib/modules/<uname -r>. These files contain information about the modules, such as their dependencies. However, the man page specifically mentions that these files should not be read or used by any additional utilities as they may be subject to change in the future. libkmod handles dependencies internally.WARNING: libkmod does not allow for static compilation, so we have to remove the static ldflag for building the init binary. This is a breaking change with older versions of hcsshim, since now we MUST have certain files present in the UVM for the init to run. If those files are not present, we will simply fail to start the UVM with an unintuitive error message.
Future work: