Open hannesm opened 5 years ago
taking a step back, maybe it helps to document what the current state of things is:
Mirage_kv.RW
), which is programmed against in a unikerneltype rw = RW and let rw = Type RW
in mirage_impl_kv.mlkv_rw
implementation that is selectable is defined in mirage_impl_kv
as well:
pclock
) / type (used to generate the functor application) method ty = pclock @-> rw
method packages = Key.pure [ package ~min:"1.2.3" "mirage-kv-unix" ]
Mirage_kv_unix
connect
function (receiving the module_name and values for its dependencies, outputting OCaml code for main.ml -- usually %s.connect () modname
-- but can of course be more complex)direct_kv_rw
function (string -> rw Functoria.impl
) -- used in various config.ml -- which depending on the target (-t yyy
) selects the default implementation (this is not present atm, but there's a direct_kv_ro
-- think of an analogous one for rw
)We discussed storing the information what devices are available/implements which interfaces in OPAM metadata to make the information available without having to hardcode it in noconfig
or mirage
.
This will allow library authors to self-declare, which should make it more ergonomic to develop against.
It will allow noconfig
to display a list of implementations for the user to choose from.
Concretely, for device implementations we will need:
kv-ro
or Mirage_kv.RO
(unclear if this should be a pet name or the name of a specific type or signature -- if we do that, maybe need to refer to opam package where that can be found?)ocamlfind
/findlib
packages should be linked in order to build, e.g. mirage-kv-unix
or tls.mirage
Tcpip_stack_direct
unix
, spt
, hvt
, genode
, etc) this implementation works on. Maybe we can use the OPAM constraint syntax for this.noconfig
can display, like "the crunch target will embed the files inside the unikernel image at compile-time"We discussed encoding this either into OPAM feature
keys, or keys prefixed with x-
(which we think are available).
(continued): Some of these fields can under various circumstances be inferred, that would be nice to bring down the amount of boilerplate device implementers have to write.
in respect to the name, I'd suggest to use the interface name -- Mirage_kv.RO
-- since in the end that's what we're working on anyways ;) -- note that the opam dependency is already defined in the opam file (i.e. that it'll need the mirage-kv
package), so we don't need that one.
potential examples follow:
x-mirage-implements: "Mirage_net.S:Netif" {target = "solo5"}
for mirage-net-solo5x-mirage-implements: "Mirage_net.S:Netif" {target = "unix"}
for mirage-net-unixx-mirage-implements: "Mirage_stack.V4:Tcpip_stack_socket.Make:stack-socket" {target = "unix"}
for tcpipx-mirage-implements: "Mirage_stack.V4:Tcpip_stack_direct.Make:stack-direct"
for tcpipx-mirage-implements: "Mirage_protocols.TCP:Flow.Make:tcp"
for tcpipcertainly, the interface name could be part of the key (if that eases opam queries): x-mirage-implements-mirage-net-s
(TODO figure out what are the allowed characters in keys)
KV
is the canonical example that has a variety of implementations we'd like to support:kv-mem
kv-unix
(-t unix
only)kv-dns
(NYI)kv-git
kv-fat
(atm via fs bridge)crunch
(RO)in MirageOS atm the unikernel developer has to select which implementation should be used, which is wrong. instead, for any unikernel with such a KV device
(KEYS : KV_RO)
,noconfig
should offer an optional--kv-keys=[mem|unix|dns|git|fat|crunch]
(nocrunch
ifKV_RW
) and emit the necessary boilerplate (including boot parameters etc.).