This session is all about Unikernels and rusty-hermit.
Find the slides online
containers where yesterday, today we'll package our web service as OS and run it directly on a hypervisor
maybe slides?
make sure you have them all updated.
git submodules init
git submodules update
We going to use Qemu as hypervisor, let's install it.
Windows users might look up their dependencies, sorry I have not tested it.
sudo apt-get update --fix-missing
sudo apt-get install qemu-system-x86 nasm
brew install qemu nasm
Note: this is not needed, because rust checks the file
rust-toolchain
and make sure everything runs as defined in that file.
for completeness that is essentially whats happening:
rustup default nightly
rustup component add rust-src llvm-tools-preview
cargo install cargo-download
cd rusty-loader
release=1 make
cd hello-hermit
cargo run --release
What we should get is something like this:
[LOADER] Loader: [0x100000 - 0x31a018]
[LOADER] Found Multiboot information at 0x9500
[LOADER] Found module: [0x31c000 - 0x5113d0]
[LOADER] Module length: 0x1f53d0
[LOADER] Found an ELF module at 0x31c000
[LOADER] Map 228 pages at 0x31c000 (page size 4 KByte)
[LOADER] Map 1 pages at 0x400000 (page size 2048 KByte)
....
[0][INFO] ===================== MULTIPROCESSOR INFORMATION =====================
[0][INFO] APIC in use: xAPIC
[0][INFO] Initialized CPUs: 1
[0][INFO] ======================================================================
[0][INFO]
[0][INFO] Compiled with PCI support
[0][INFO] Compiled with ACPI support
[0][INFO] Compiled with SMP support
[0][INFO] HermitCore is running on common system!
Hello World!
[0][INFO] Number of interrupts
[0][INFO] [0][7]: 1
[0][INFO] Shutting down system
🚀 Congrats! The first application as OS has been launched
NOTE: the demo project has a
.cargo/config
file that describes the target architecture, features and the runner, that isqemu
in this case
Note: it's possible to use a tun network device, here you can read more
We are using here a port forwarded network setup. The echo server listens on port 8080
.
Note: for this we need an additional feature to add:
dhcpv4
cd echo-hermit
cargo run --release
should output something like:
Finished release [optimized] target(s) in 0.06s
Running `qemu-system-x86_64 -device rtl8139,netdev=net0 -netdev 'user,id=net0,hostfwd=tcp::8080-:8080' -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr -display none -smp 1 -m 64M -serial stdio -kernel ../rusty-loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release/echo-hermit`
[LOADER] Loader: [0x100000 - 0x31a018]
[LOADER] Found Multiboot information at 0x9500
...
[0][INFO] Compiled with PCI support
[0][INFO] Compiled with ACPI support
[0][INFO] Compiled with SMP support
[0][INFO] HermitCore is running on common system!
[0][INFO] Found Realtek network device with device id 0x8139
[0][INFO] RTL8139: CR = 0xd, ISR = 0x0, speed = 10 mbps
[INFO] Spawn network thread with id 2
[INFO] MAC address 52-54-00-12-34-56
[INFO] MTU: 1500 bytes
[INFO] Assigned a new IPv4 address: 10.0.2.15/24
[INFO] Default gateway: 10.0.2.2
[INFO] DNS servers:
[INFO] - 10.0.2.3
telnet localhost 8080
hello hermit
hello hermit
We won't cover that today, but there is a nice wiki page about how one can run RustyHermit on KubeVirt.
- github/hermitcore
- hermit/playground
- macos/tuntaposx/faq
- macos/qemu-bridging
- qemu/networking
- qemu/macos-specifics
- remove a network bridge interface:
sudo ifconfig <bridge01> destroy
- create a tun interface:
brew install tuntap && sudo ifconfig tun0 create
- check route to host:
traceroute 10.0.5.3
- add a route to one (first) host via (second) gateway:
sudo route add 10.0.5.3 10.0.5.1
- qemu supported models:
qemu-system-x86_64 -nic model=help
sudo ip tuntap add tap10 mode tap
sudo ip addr add 10.0.5.1/24 broadcast 10.0.5.255 dev tap10
sudo ip link set dev tap10 up
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap10/proxy_arp'
# sudo route add -net 10.0.5.0/24 gw 10.0.5.1
Note: when running qemu must provide the right network device with those options
qemu-system-x86_64
options:
-netdev tap,id=net0,ifname=tap10,script=no,downscript=no,vhost=on
-device virtio-net-pci,netdev=net0,disable-legacy=on
-m 512M
memory needs to be at least512M
Note: you can control the network properties via env variables
HERMIT_VERBOSE=1 HERMIT_IP="10.0.5.3" HERMIT_GATEWAY="10.0.5.2" HERMIT_MASK="255.255.255.0" HERMIT_NETIF=bridge102 cargo run --release