Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Mirage OS hackaton December 2017

Personal notes on MirageOS, Ocaml ecosystem and charrua-core (Ocaml DHCP client).

Thanks so much @hannesm for organizing it.

Install ocaml, opam and mirage in Debian testing/sid

Following Mirage Install:

apt install install ocaml ocaml-native-compilers camlp4-extra opam
opam init
eval `opam config env`

opam install mirage

Install charrua-core (DHCP client) local branch

git clone
cd charrua-core
git checkout -b mybranch
opam pin add charrua-core .

The installed code would be now in $HOME/.opam

Use charrue-core in utop

Use charrue-core in utop (with help from @cfcs)

#load "/home//user/.opam/system/lib/io-page-unix/io_page_unix.cma";;
#require "charrua-core";;
#require "charrua-core.wire";;
open Dhcp_wire;;

Ocaml/Python equivalences

open Dhcp_wire;;

equivalent to:

import * from DHCP_wire

Run charrua client in unix

DHCP client (which doesn't set an IP) by @yomimono:

git clone 
git checkout unix-charruac
jbuilder build -p charrua-unix

sudo _build/default/unix/client/charruac.exe

In case it's needed to rebuild dependencies:

jbuilder clean -p charrua-client
jbuilder clean -p charrua-client-lwt
jbuilder clean -p charrua-core
jbuilder build --dev @install -p charrua-unix

sudo _build/default/unix/client/charruac.exe

To use last master version of rawlink (thanks to @yomimono and @haesbaert):

git clone
cd rawlink
opam pin add rawlink ./

Create solo5 unikernel with charrua-core

(With help from @mato)

When there's a in the module

mirage configure -t unix
make depend

When there isn't. Create a tun/tap interface:

ip tuntap add tap100 mode tap
ip addr add dev tap100
ip link set dev tap100 up

Then bridge to the tun/tap interface, in /etc/network/interfaces:

# Host-only bridge
iface hostbr0 inet manual
    up ip link add hostbr0-master address 02:00:00:00:00:01 type dummy
    up ip link set dev hostbr0-master up
    up ip link add hostbr0 type bridge
    up ip link set dev hostbr0-master master hostbr0
    up ip addr add dev hostbr0
    up ip link set dev hostbr0 up
    post-up /usr/sbin/dnsmasq -9RhK -i hostbr0 -F, -p 0 -x /var/run/
    pre-down kill $(cat /var/run/
    down ip link del hostbr0
    down ip link del hostbr0-master

With an IP

cd mirage-skeleton/device-usage/network
opam switch
opam list
mirage configure -t ukvm
make depend
./ukvm-bin --net=tap100 ./network.ukvm --ipv4= --logs=\*:debug


cd mirage-skeleton/device-usage/network
rm mirage-unikernel-network-ukvm.opam 
mirage configure -t ukvm --DHCP=true
make depend
./ukvm-bin --net=tap100 ./network.ukvm  --logs=\*:debug 

To use the local charrua-core git branch:

cd charrua-core 
opam pin add charrua-client-mirage ./

cd mirage-skeleton/device-usage/network
mirage clean
mirage configure -t ukvm --DHCP=true
./ukvm-bin --net=tap100 ./network.ukvm  --logs=\*:debug 

Execute an script from Ocaml

(Helped by @reynir and @yomimono) Using Bos library

Without envirnoment variables:

#require "bos";;
open Bos;;
OS.Cmd.to_null (OS.Cmd.run_io Cmd.(Cmd.v "mplayer" % "example.ogg") OS.Cmd.in_null);;

Passing envirnoment variables:

let myenv = Astring.String.Map.empty;;
let myenv = Astring.String.Map.add "reason" "foo" myenv;;
OS.Cmd.to_null (OS.Cmd.run_io ~env:myenv Cmd.(Cmd.v "/sbin/dhclient-script") OS.Cmd.in_null);;

To see the environment variables passed to the script:

let myres = OS.Cmd.to_string (OS.Cmd.run_io ~env:myenv Cmd.(Cmd.v "/usr/bin/env") OS.Cmd.in_null);;
let mystr = match myres with
  | Result.Ok anything -> anything;;
print_endline letmystr;;


No description, website, or topics provided.



No releases published


No packages published
You can’t perform that action at this time.