reflect that changes are now upstreamed

This commit is contained in:
Hannes Mehnert 2016-10-20 00:03:09 +01:00
parent bdc5d8d0f1
commit 19feb8b342

View file

@ -5,6 +5,8 @@ tags: future, mirageos, security
abstract: MirageOS solo5 multiboot native on bhyve
---
Update (2016-10-19): all has been merged upstream now!
There were some busy times, several pull requests are still waiting to get merged (e.g. some cosmetics in [mirage](https://github.com/mirage/mirage/pull/544) as preconditions for treemaps and dependency diagrams), I [proposed](https://github.com/mirage/mirage/pull/547) to use `sleep_ns : int64 -> unit io` instead of the `sleep : float -> unit io` (nobody wants floating point numbers); also an RFC for [random](https://github.com/mirage/mirage/pull/551), Matt Gray [proposed](https://github.com/mirage/mirage/pull/548) to get rid of `CLOCK` (and have a `PCLOCK` and a `MCLOCK` instead). Soon there will be a major MirageOS release which breaks all the previous unikernels! :)
## What?
@ -25,34 +27,16 @@ While lots of people seem to like KVM and Linux, I still prefer FreeBSD, their j
These instructions are still slightly bumpy. If you've a FreeBSD with bhyve (I use FreeBSD-CURRENT), and OCaml and opam (>=1.2.2) installed, it is pretty straightforward to get solo5 running. First, I'd suggest to use a fresh opam switch in case you work on other OCaml projects: `opam switch -A solo5 4.03.0` (followed by ``eval `opam config env` `` to setup some environment variables).
You need some software from the ports (this should be cleaned up at some point), at the moment `devel/gmake`, `devel/binutils`, and `sysutils/grub2-bhyve`.
You need some software from the ports: `devel/pkgconf`, `devel/gmake`, `devel/binutils`, and `sysutils/grub2-bhyve`.
Some header files from the system need to be included in the search path:
Lots of libraries are not yet released, use the [`mirage-dev`](https://github.com/mirage/mirage-dev) repository:
```bash
TMP="/tmp/myinclude"
mkdir $TMP $TMP/sys $TMP/x86 $TMP/machine
cd /usr/include
cp machine/_stdint.h machine/_types.h machine/endian.h $TMP/machine
cp sys/_null.h sys/_stdint.h sys/_types.h sys/cdefs.h sys/endian.h $TMP/sys
cp x86/float.h x86/_stdint.h x86/stdarg.h x86/endian.h x86/_types.h $TMP/x86
cp float.h osreldate.h stddef.h stdint.h stdbool.h stdarg.h $TMP
```
A bunch of opam pins are needed (using pins instead of the [solo5 repository](https://github.com/Solo5/opam-solo5/) since pins are local to compiler switches, whereas repositories are global, and I needed to modify some bits anyways):
```bash
opam pin add -n solo5-kernel-virtio https://github.com/hannesm/solo5.git#FreeBSD
opam pin add -n ocaml-freestanding https://github.com/hannesm/ocaml-freestanding.git#FreeBSD
opam pin add -n mirage --dev-repo
opan pin add -n mirage-entropy-solo5 --dev-repo
opam pin add -n nocrypto https://github.com/hannesm/ocaml-nocrypto.git#p
opam repo add mirage-dev https://github.com/mirage/mirage-dev.git
```
An `opam install mirage mirage-logs solo5-kernel-virtio mirage-bootvar-solo5 mirage-console mirage-solo5` should provide you with a basic set of libraries.
On FreeBSD, we'll need `setenv LD /usr/local/bin/ld` to get the linker from the ports (system linker does not generate good binaries).
Now you can get the [mirage-skeleton](https://github.com/mirage/mirage-skeleton) repository, and inside of `console`, run `mirage configure --no-opam --virtio` followed by `gmake`. There should be a resulting `mir-console.virtio`.
Now you can get the [mirage-skeleton](https://github.com/mirage/mirage-skeleton) repository, and inside of `console`, run `mirage configure --no-opam --virtio` followed by `make`. There should be a resulting `mir-console.virtio`.
Once that is in place, start your VM:
```bash
@ -87,14 +71,11 @@ Kernel done.
Goodbye!
```
I have not yet played with network, TLS, and other things...
Network and TLS stack is supposed to work as well.
## Open issues
- There are several things to upstream, such as the clang changes and FreeBSD support for ocaml-freestanding and other libraries ([this tracking issue](https://github.com/Solo5/solo5/issues/61))
- The `Makefile` generated by mirage should be in the intersection of BSD and GNU make
- I'm not happy to require `ld` from the ports (but the one in base does not produce sensible binaries with `-z max-page-size=0x1000` [related](https://github.com/Solo5/solo5/pull/56))
- I'm also not happy to copy around include files and depend on gcc just for `stddef.h`, is there any sensible way to have freestanding includes? Should `-nostdinc` be used? (It looks necessary on Linux).
- Via [twitter](https://twitter.com/bhyve_dev/status/748930600581492736), bhyve devs suggested to port ukvm to ubhyve. This is a great idea, to no longer depend on virtio, and get more speed. Any takers?
- Debugging via gdb should be doable somehow, bhyve has [some support for gdb](https://wiki.freebsd.org/bhyve/DebuggingWithGdb), but it is unclear to me what I need to do to enter the debugger (busy looping in the VM and a gdb remote to the port opened by bhyve does not work).