c/agent: log to extra kernel consoles
Currently the list of consoles to which logtree output is piped is
hardcoded to be tty0 (the first virtual console) as well as ttyS0
(the first platform serial port). On some platforms this is
insufficient, so also log to any kernel consoles defined.
The same problem exists for Metropolis itself, but there we first need a
mechanism to pass a per-machine command line as for safety reasons it's
currently hardcoded in the stub loader.
Change-Id: I918525ed69a87323cbea561f3500b2166c842aae
Reviewed-on: https://review.monogon.dev/c/monogon/+/1511
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/cloud/takeover/takeover.go b/cloud/takeover/takeover.go
index e340c56..fc71690 100644
--- a/cloud/takeover/takeover.go
+++ b/cloud/takeover/takeover.go
@@ -130,10 +130,9 @@
agentParams := bootparam.Params{
bootparam.Param{Param: "quiet"},
bootparam.Param{Param: "init", Value: "/init"},
- // Always add "default" console on x86
- bootparam.Param{Param: "console", Value: "ttyS0,115200"},
}
+ var customConsoles bool
cmdline, err := os.ReadFile("/proc/cmdline")
if err != nil {
warnings = append(warnings, fmt.Errorf("unable to read current kernel command line: %w", err))
@@ -145,10 +144,15 @@
for _, p := range params {
if p.Param == "console" {
agentParams = append(agentParams, p)
+ customConsoles = true
}
}
}
}
+ if !customConsoles {
+ // Add the "default" console on x86
+ agentParams = append(agentParams, bootparam.Param{Param: "console", Value: "ttyS0,115200"})
+ }
agentCmdline, err := bootparam.Marshal(agentParams, "")
// Stage agent payload into kernel memory
if err := kexec.FileLoad(kernelFile, initramfsFile, agentCmdline); err != nil {