icexin / eggos

A Go unikernel running on x86 bare metal
http://eggos.icexin.com
MIT License
2.21k stars 112 forks source link

Loading various Init() functions in eggos.go #98

Closed jspc closed 2 years ago

jspc commented 2 years ago

Thanks for merging https://github.com/icexin/eggos/pull/96, it's really helped me debug the issues I'm having.

The problem is that I'm missing logs which happen in init() functions in eggos, due to the order in which init functions run- source files are loaded in alphabetical order, the packages are loaded, and those init functions are added to the run order first, then the ones in the main package.

This means in order to set the log level you need to do something a bit gory like I've done here - create a file which is guaranteed to be parsed first (I prefixed mine with 00_) and have that include a package whose init function only exists to call out to set the log level.

Now if that's the way you want this problem solving, then that's fine (I can keep this approach), but I think a better approach would be to change the build tool to:

  1. Generate a file in the build dir called, for instance, zz_eggos.go (following conventions from tools like the operator SDK)
  2. Write to this file the contents of the current eggos.go file (rather than importing it, which will allow us to avoid the top)

I'd also like to make a minor change to how drivers and stuff are initialised. Rather than having them panic() out, which exits on baremetal and, in my case, clears output (so I can't even see what failed and why) I'd like them to print errors to the console and halt so that the output exists long enough to read. Ignore this, it's an ordering issue with where the panic trap happens, which I will fix.

But I can open a new issue to discuss that design.

jspc commented 2 years ago

Closing, discussion in https://github.com/icexin/eggos/pull/99