m/installer: support kernel modules with firmware
Add device manager runnable and associated metadata, loadable kernel
modules and firmware. This is required to run the installer on platforms
which require loadable firmware to access storage devices.
Change-Id: I680c741df23693a8810220e4831e8bd45afca580
Reviewed-on: https://review.monogon.dev/c/monogon/+/4391
Reviewed-by: Jan Schär <jan@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/installer/BUILD.bazel b/metropolis/installer/BUILD.bazel
index 72fee1a..3522644 100644
--- a/metropolis/installer/BUILD.bazel
+++ b/metropolis/installer/BUILD.bazel
@@ -13,7 +13,9 @@
importpath = "source.monogon.dev/metropolis/installer",
visibility = ["//visibility:private"],
deps = [
+ "//go/logging",
"//metropolis/installer/install",
+ "//metropolis/node/core/devmgr",
"//osbase/blockdev",
"//osbase/bringup",
"//osbase/efivarfs",
@@ -39,6 +41,7 @@
},
fsspecs = [
"//osbase/build:earlydev.fsspec",
+ "//third_party:firmware",
],
visibility = ["//metropolis/installer/test:__pkg__"],
)
diff --git a/metropolis/installer/main.go b/metropolis/installer/main.go
index 6ecc26e..930c472 100644
--- a/metropolis/installer/main.go
+++ b/metropolis/installer/main.go
@@ -18,7 +18,9 @@
"golang.org/x/sys/unix"
+ "source.monogon.dev/go/logging"
"source.monogon.dev/metropolis/installer/install"
+ "source.monogon.dev/metropolis/node/core/devmgr"
"source.monogon.dev/osbase/blockdev"
"source.monogon.dev/osbase/bringup"
"source.monogon.dev/osbase/efivarfs"
@@ -55,7 +57,7 @@
// findInstallableBlockDevices returns names of all the block devices suitable
// for hosting a Metropolis installation, limited by the size expressed in
// bytes minSize. The install medium espDev will be excluded from the result.
-func findInstallableBlockDevices(espDev string, minSize uint64) ([]string, error) {
+func findInstallableBlockDevices(l logging.Leveled, espDev string, minSize uint64) ([]string, error) {
// Use the partition's name to find and return the name of its parent
// device. It will be excluded from the list of suitable target devices.
srcDev, err := sysfs.ParentBlockDevice(espDev)
@@ -92,9 +94,10 @@
// Skip devices of insufficient size.
devPath := filepath.Join("/dev", devInfo.Name())
- dev, err := blockdev.Open(devPath)
+ dev, err := blockdev.Open(devPath, blockdev.WithReadonly)
if err != nil {
- return nil, fmt.Errorf("couldn't open a block device at %q: %w", devPath, err)
+ l.Warningf("couldn't open a block device at %q, ignoring: %v", devPath, err)
+ continue
}
devSize := uint64(dev.BlockCount() * dev.BlockSize())
dev.Close()
@@ -118,6 +121,9 @@
l.Info(copyrightLine)
l.Info("")
+ devmgrSvc := devmgr.New()
+ supervisor.Run(ctx, "devmgr", devmgrSvc.Run)
+
// Validate we are running via EFI.
if _, err := os.Stat("/sys/firmware/efi"); os.IsNotExist(err) {
// nolint:ST1005
@@ -187,7 +193,7 @@
installParams.PartitionSize.Data + 1) * mib)
// Look for suitable block devices, given the minimum size.
- blkDevs, err := findInstallableBlockDevices(espDev, minSize)
+ blkDevs, err := findInstallableBlockDevices(l, espDev, minSize)
if err != nil {
return err
}