Closed prologic closed 2 years ago
Thanks for the report @prologic
Remove the current path .
in the command line, and run egg build
directly in the project directory. egg
have bugs when specifying the build path. I will try to fix it.
That worked! Quick too!
Next question 🤣
How do I use egg run
?:
(⎈ |local:default)
prologic@Jamess-iMac
Fri Aug 06 12:16:29
~/tmp/hello-eggos
130
$ ls
go.mod go.sum hello-eggos main.go
(⎈ |local:default)
prologic@Jamess-iMac
Fri Aug 06 12:16:31
~/tmp/hello-eggos
0
$ egg run ./hello-eggos
2021/08/06 12:16:35 missing kernel file
The -k
flag specifies the kernel file. In your example, you can use egg run -k hello-eggos
Ahh I see! So it's actually a "kernel" that's output. Got it!
Why not just make it the argument to egg run
? e.g: egg run hello-eggos
?
Why not just make it the argument to
egg run
? e.g:egg run hello-eggos
?
Good suggestion!
it works! 🎉
We might need ways to control qemu options too like running in headless mode, etc...
You can specify qemu parameters after --
, such as -- -nographic
to make qemu not display the window.
The complete command is as follows
egg run -k hello-eggos -- -nographic
I hacked egg run
a bit to do this:
Basically simplify the usage and take qemu options from QEMU_OPTS
environment variable so egg run
options can be egg specific only and not get confuging.
Interesting in a PR for this?
Interesting in a PR for this?
@prologic welcome!
We can also borrow some ideas from here: https://github.com/nanovms/ops/tree/master/qemu or reuse some of it's sub-packages.
Here is my branch so far https://git.mills.io/prologic/eggos/compare/main...simplify_run_test_qemu_opts
Feel free to comment there or here, I don't publish code to Github anymore 😭
Here is my branch so far https://git.mills.io/prologic/eggos/compare/main...simplify_run_test_qemu_opts
Thanks!
Feel free to comment there or here, I don't publish code to Github anymore 😭
Sorry to hear that.
We can also borrow some ideas from here: https://github.com/nanovms/ops/tree/master/qemu or reuse some of it's sub-packages.
Good! At present, the purpose of egg run
is to verify the correctness of the kernel as a playground, so its feature is relatively simple, and it does not wrap the parameters of qemu too much.
What do you think? @prologic
Feel free to comment there or here, I don't publish code to Github anymore 😭
Sorry to hear that.
Yeah it's a long story, but you can read about it here (if you're curious).
We can also borrow some ideas from here: https://github.com/nanovms/ops/tree/master/qemu or reuse some of it's sub-packages.
Good! At present, the purpose of
egg run
is to verify the correctness of the kernel as a playground, so its feature is relatively simple, and it does not wrap the parameters of qemu too much.What do you think? @prologic
Yeah this is why I think removing the options from egg run
and egg run
and putting them behind QEMU_OPTS
env var makes more sense IHMO. It also simplifies how egg run
and egg test
actually work too.
It might (with more work) be possible to make egg run
and egg test
take no arguments and implicitly to some checks, run build if necessary and just automagically workout what the built kernel is.
It might (with more work) be possible to make egg run and egg test take no arguments and implicitly to some checks, run build if necessary and just automagically workout what the built kernel is.
egg test
is actually run like this, it will automatically compile the unit test file, and then run it in qemu.
Shall I make egg run
have the same behaviour if no argument is provided?
Maybe it is more convenient for egg run
to not specify parameters, but egg run
can run ISO file in addition to ELF file. I prefer to explicitly compile kernel with egg build
and then run the kernel with egg run
.
Maybe we can let the user explicitly specify the parameters to make egg run
automatically compile the kernel before running?
This works both ways now 😀
In other words egg build
and egg run
are behaving more like go build
and go run
.
You can still explicitly build and run with my branch.
In fact, it is more complicated to deal with projects without a go.mod file. egg
will automatically add an import_eggos.go
file to the project to import eggos when building the project, and at the same time add a dependency on eggos in the go.mod
file. Therefore egg build
must be in a project where go.mod exists to compile correctly.
Therefore, egg run
or egg build
must build a complete go module project in the temporary directory when processing a single go file to run normally.
So I can remove the fallback on the project directory name?
Because egg test
has already compiled the package and has output file, runKernel
should only run the kernel file, and the part of compiling the kernel can be put into a function separately.
In addition, the code in runTest should look like this
runKernel([]string{outfile})
Good point I'll amend that.
@prologic thanks for your contribution. Do you mind if I merge the code into a PR and submit it to GitHub?
Absolutely not! I just don't want to host any of my own code (or forks) on Github anymore, but I will still be a happy participant of open source 😀 -- Sorry for the slightly extra work though. Btw my Gitea instance accepts Github OAuth in case that's convenience fo ryou.
Also I just tries a simple "Hello World" web server and it works!
$ egg run -p 8000:8000
...
🎉
Next thing I'm going to improve is passing signals (SIGINT
and SIGTERM
) from the host where egg run
is being run to the guest os (egg application).
This is pretty amazing shit you've built here btw 😂 I'm loving this! Leet it up! This may very well turn out to be a really really good way of building super secure applications 👌
It reminds me of nonovms's ops project just better 🤣
I tried
egg build
on something very simple:It might be the last 3 lines here:
Bug?