m/n/core: fix panic logging
We fix a few issues:
1. Logging to the runtime file descriptors didn't work for some
reason. Opening the FD(s) manually works.
2. We didn't log into consoles.
3. We didn't return errors/results correctly. RawSyscall performs its
own '>0' check on a syscall result and routes the result to either
the first or last return value. We need to undo this check to return
the same unified argument as runtime.write expects and
runtime.write1 provides.
Change-Id: Ie718a47139dd0f700d53466a1250593025c9dcbd
Reviewed-on: https://review.monogon.dev/c/monogon/+/809
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/core/main.go b/metropolis/node/core/main.go
index c6b0bd3..5fde55b 100644
--- a/metropolis/node/core/main.go
+++ b/metropolis/node/core/main.go
@@ -45,10 +45,9 @@
// Set up logger for Metropolis. Currently logs everything to /dev/tty0 and
// /dev/ttyS0.
+ consoles := []string{"/dev/tty0", "/dev/ttyS0"}
lt := logtree.New()
- for _, p := range []string{
- "/dev/tty0", "/dev/ttyS0",
- } {
+ for _, p := range consoles {
f, err := os.OpenFile(p, os.O_WRONLY, 0)
if err != nil {
continue
@@ -66,7 +65,7 @@
}(p, f)
}
// Initialize persistent panic handler early
- initPanicHandler(lt)
+ initPanicHandler(lt, consoles)
// Initial logger. Used until we get to a supervisor.
logger := lt.MustLeveledFor("init")