Skip to content

Commit

Permalink
init: allow force loading of extra modules via the kernel command-line
Browse files Browse the repository at this point in the history
[Anatol]: change parameter name to `rd.modules_force_load'; add integration test

Fixes #186
  • Loading branch information
nmeum authored and anatol committed Oct 10, 2022
1 parent c1b6667 commit 2b49c7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/manpage.md
Expand Up @@ -117,6 +117,7 @@ Some parts of booster boot functionality can be modified with kernel boot parame
* `rd.luks.key=$UUID=$PATH` absolute path to a keyfile in the initrd/initramfs which can be unsed to unlock the device identified by UUID, if this file does not exist or fails to unlock it will fall back to a password request.
* `rd.luks.options=opt1,opt2` a comma-separated list of LUKS flags. Supported options are `discard`, `same-cpu-crypt`, `submit-from-crypt-cpus`, `no-read-workqueue`, `no-write-workqueue`.
Note that booster also supports LUKS v2 persistent flags stored with the partition metadata. Any command-line options are added on top of the persistent flags.
* `rd.modules_force_load` a comma-separated list of extra kernel modules which should be force loaded.
* `resume=$deviceref` device reference to suspend-to-disk device.
* `zfs=$pool/$dataset` specifies what ZFS dataset needs to be used for root partition. This option is only used if ZFS config option is enabled. If ZFS filesystem is enabled then `root=` boot param is ignored.
* `booster.log` configures booster init logging. It accepts a comma separated list of following values:
Expand Down
6 changes: 6 additions & 0 deletions init/cmdline.go
Expand Up @@ -192,7 +192,13 @@ func parseParams(params string) error {
if err != nil {
return fmt.Errorf("root=%s: %v", value, err)
}
case "rd.modules_force_load":
if value == "" {
break
}

modules := strings.Split(value, ",")
config.ModulesForceLoad = append(config.ModulesForceLoad, modules...)
case "resume":
var err error
cmdResume, err = parseDeviceRef(value)
Expand Down
13 changes: 13 additions & 0 deletions tests/integration_test.go
Expand Up @@ -224,3 +224,16 @@ func TestUsb(t *testing.T) {

require.NoError(t, vm.ConsoleExpect("Hello, booster!"))
}

func TestLoadExtraModules(t *testing.T) {
vm, err := buildVmInstance(t, Opts{
disk: "assets/ext4.img",
kernelArgs: []string{"root=LABEL=atestlabel12", "rd.modules_force_load=foo,xfs"},
})
require.NoError(t, err)
defer vm.Shutdown()

require.NoError(t, vm.ConsoleExpect("booster: finit(foo): open /usr/lib/modules/foo.ko: no such file or directory"))
require.NoError(t, vm.ConsoleExpect("booster: loading module xfs"))
require.NoError(t, vm.ConsoleExpect("Hello, booster!"))
}

0 comments on commit 2b49c7c

Please sign in to comment.