Module Mirage

module Mirage: sig .. end
Mirage combinators.

Mirage devices a set of devices and combinator to to define portable applications across all platforms that MirageOS supports.

Release v2.9.0-37-g69e9c87


module Key: module type of struct include Mirage_key end
Configuration keys.
include Functoria_app.DSL

General mirage devices


type tracing 
The type for tracing.
val tracing : tracing typ
Implementation of the Mirage.tracing type.
val mprof_trace : size:int -> unit -> tracing impl
Use mirage-profile to trace the unikernel. On Unix, this creates and mmaps a file called "trace.ctf". On Xen, it shares the trace buffer with dom0.

Time


type time 
Abstract type for timers.
val time : time typ
Implementations of the V1.TIME signature.
val default_time : time impl
The default timer implementation.

Clocks


type clock 
Abstract type for clocks.
val clock : clock typ
Implementations of the V1.CLOCK signature.
val default_clock : clock impl
The default mirage-clock implementation.

Log reporters


type reporter 
The type for log reporters.
val reporter : reporter typ
Implementation of the log Mirage.reporter type.
val default_reporter : ?clock:clock impl ->
?ring_size:int -> ?level:Logs.level -> unit -> reporter impl
default_reporter ?clock ?level () is the log reporter that prints log messages to the console, timestampted with clock. If not provided, the default clock is Mirage.default_clock. level is the default log threshold. It is Logs.Info if not specified.
val no_reporter : reporter impl
no_reporter disable log reporting.

Random


type random 
Abstract type for random sources.
val random : random typ
Implementations of the V1.RANDOM signature.
val default_random : random impl
Passthrough to the OCaml Random generator.

Consoles


type console 
Abstract type for consoles.
val console : console typ
Implementations of the V1.CONSOLE signature.
val default_console : console impl
Default console implementation.
val custom_console : string -> console impl
Custom console implementation.

Memory allocation interface


type io_page 
Abstract type for page-aligned buffers.
val io_page : io_page typ
Implementations of the V1.IO_PAGE signature.
val default_io_page : io_page impl
The default Io_page implementation.

Block devices


type block 
Abstract type for raw block device configurations.
val block : block typ
Implementations of the V1.BLOCK signature.
val block_of_file : string -> block impl
Use the given filen as a raw block device.

Static key/value stores


type kv_ro 
Abstract type for read-only key/value store.
val kv_ro : kv_ro typ
Implementations of the V1.KV_RO signature.
val crunch : string -> kv_ro impl
Crunch a directory.
val archive : block impl -> kv_ro impl
val archive_of_files : ?dir:string -> unit -> kv_ro impl
val direct_kv_ro : string -> kv_ro impl
Direct access to the underlying filesystem as a key/value store. For Xen backends, this is equivalent to crunch.

Filesystem


type fs 
Abstract type for filesystems.
val fs : fs typ
Implementations of the V1.FS signature.
val fat : ?io_page:io_page impl -> block impl -> fs impl
Consider a raw block device as a FAT filesystem.
val fat_of_files : ?dir:string -> ?regexp:string -> unit -> fs impl
fat_files dir ?dir ?regexp () collects all the files matching the shell pattern regexp in the directory dir into a FAT image. By default, dir is the current working directory and regexp is *
val kv_ro_of_fs : fs impl -> kv_ro impl
Consider a filesystem implementation as a read-only key/value store.

Generic key/value stores


val generic_kv_ro : ?key:[ `Archive | `Crunch | `Fat ] value -> string -> kv_ro impl
Generic key/value that will choose dynamically between Mirage.fat, Mirage.archive and Mirage.crunch.

If no key is provided, it uses Key.kv_ro to create a new one.


Network interfaces


type network 
Abstract type for network configurations.
val network : network typ
Implementations of the V1.NETWORK signature.
val tap0 : network impl
The '/dev/tap0' interface.
val netif : ?group:string -> string -> network impl
A custom network interface. Exposes a Key.network key.

Ethernet configuration


type ethernet 
val ethernet : ethernet typ
Implementations of the V1.ETHIF signature.
val etif : network impl -> ethernet impl

ARP configuration


type arpv4 
val arpv4 : arpv4 typ
Implementation of the V1.ARPV4 signature.
val arp : ?clock:clock impl ->
?time:time impl -> ethernet impl -> arpv4 impl

IP configuration

Implementations of the V1.IP signature.

type v4 
type v6 
type 'a ip 
Abstract type for IP configurations.
type ipv4 = v4 ip 
type ipv6 = v6 ip 
val ipv4 : ipv4 typ
The V1.IPV4 module signature.
val ipv6 : ipv6 typ
The V1.IPV6 module signature.
type ('ipaddr, 'prefix) ip_config = {
   address : 'ipaddr;
   netmask : 'prefix;
   gateways : 'ipaddr list;
}
Types for IP manual configuration.
type ipv4_config = (Ipaddr.V4.t, Ipaddr.V4.t) ip_config 
Types for IPv4 manual configuration.
val create_ipv4 : ?clock:clock impl ->
?time:time impl ->
?group:string ->
network impl -> ipv4_config -> ipv4 impl
Use an IPv4 address. Exposes the keys Key.V4.ip, Key.V4.netmask and Key.V4.gateways.
val default_ipv4 : ?group:string -> network impl -> ipv4 impl
Default local IP listening on the given network interfaces:
type ipv6_config = (Ipaddr.V6.t, Ipaddr.V6.Prefix.t list) ip_config 
Types for IPv6 manual configuration.
val create_ipv6 : ?time:time impl ->
?clock:clock impl ->
?group:string ->
network impl -> ipv6_config -> ipv6 impl
Use an IPv6 address. Exposes the keys Key.V6.ip, Key.V6.netmask and Key.V6.gateways.

UDP configuration


type 'a udp 
type udpv4 = v4 udp 
type udpv6 = v6 udp 
val udp : 'a udp typ
Implementation of the V1.UDP signature.
val udpv4 : udpv4 typ
val udpv6 : udpv6 typ
val direct_udp : 'a ip impl -> 'a udp impl
val socket_udpv4 : ?group:string -> Ipaddr.V4.t option -> udpv4 impl

TCP configuration


type 'a tcp 
type tcpv4 = v4 tcp 
type tcpv6 = v6 tcp 
val tcp : 'a tcp typ
Implementation of the V1.TCP signature.
val tcpv4 : tcpv4 typ
val tcpv6 : tcpv6 typ
val direct_tcp : ?clock:clock impl ->
?random:random impl ->
?time:time impl -> 'a ip impl -> 'a tcp impl
val socket_tcpv4 : ?group:string -> Ipaddr.V4.t option -> tcpv4 impl

Network stack configuration


type stackv4 
val stackv4 : stackv4 typ
Implementation of the V1.STACKV4 signature.
val direct_stackv4_with_default_ipv4 : ?clock:clock impl ->
?random:random impl ->
?time:time impl ->
?group:string -> network impl -> stackv4 impl
Same as Mirage.direct_stackv4_with_static_ipv4 with the default given by Mirage.default_ipv4.
val direct_stackv4_with_static_ipv4 : ?clock:clock impl ->
?random:random impl ->
?time:time impl ->
?group:string ->
network impl -> ipv4_config -> stackv4 impl
Direct network stack with ip. Exposes the keys Key.V4.ip, Key.V4.netmask and Key.V4.gateways.
val direct_stackv4_with_dhcp : ?clock:clock impl ->
?random:random impl ->
?time:time impl ->
?group:string -> network impl -> stackv4 impl
Direct network stack using dhcp.
val socket_stackv4 : ?group:string -> Ipaddr.V4.t list -> stackv4 impl
Network stack with sockets. Exposes the key .
val generic_stackv4 : ?group:string ->
?dhcp_key:bool value ->
?net_key:[ `Direct | `Socket ] value ->
network impl -> stackv4 impl
Generic stack using a dhcp and a net keys: Key.net and Key.dhcp. If a key is not provided, it uses Key.net or Key.dhcp (with the group argument) to create it.

Resolver configuration


type resolver 
val resolver : resolver typ
val resolver_dns : ?ns:Ipaddr.V4.t ->
?ns_port:int ->
?time:time impl -> stackv4 impl -> resolver impl
val resolver_unix_system : resolver impl

Entropy


val nocrypto : job impl
Device that initializes the entropy.

Conduit configuration


type conduit 
val conduit : conduit typ
val conduit_direct : ?tls:bool -> stackv4 impl -> conduit impl

HTTP configuration


type http 
val http : http typ
val http_server : conduit impl -> http impl

Argv configuration


val default_argv : Functoria_app.argv impl
default_argv is a dynamic argv implementation that resolves either to the xen or the unix implementation.
val no_argv : Functoria_app.argv impl
no_argv Disable command line parsing and set argv to |""|.

Other devices


val noop : job impl
noop is a job that does nothing, has no dependency and returns ()
type info 
info is the type for module implementing Mirage_runtime.Info.
val info : info typ
info is the combinator to generate Mirage.info values to use at runtime.
val app_info : info impl
app_info exports all the information available at configure time into a runtime Mirage.Info.t value.

Deprecated functions


val get_mode : unit -> [ `MacOSX | `Unix | `Xen ]
Deprecated.Use Key.target and Key.is_xen.
Current configuration mode.
val add_to_opam_packages : string list -> unit
Deprecated.Use the ~package argument from Mirage.register.
Register opam packages.
val add_to_ocamlfind_libraries : string list -> unit
Deprecated.Use the ~libraries argument from Mirage.register.
Register ocamlfind libraries.

Application registering


val register : ?argv:Functoria_app.argv impl ->
?tracing:tracing impl ->
?reporter:reporter impl ->
?keys:Key.t list ->
?libraries:string list ->
?packages:string list -> string -> job impl list -> unit
register name jobs registers the application named by name which will executes the given jobs.
argv : Configure command-line argument parsing. The default parser is Mirage.default_argv. To disable command-line parsing, use Mirage.no_argv.
tracing : Enable tracing.
reporter : Configure logging. The default log reporter is Mirage.default_reporter. To disable logging, use Mirage.no_reporter.
keys : The keys related to this module.
libraries : The ocamlfind libraries needed by this module.
packages : The opam packages needed by this module.