Module Mirage
Mirage combinators.
Mirage
devices a set of devices and combinator to to define portable applications across all platforms that MirageOS supports.
Release v3.10.1
module Key : module type of sig ... end
Configuration keys.
include Functoria_app.DSL
type !'d typ
= 'd Functoria.typ
=
|
Type : 'a -> 'a typ
|
Function : 'b typ * 'c typ -> ('b -> 'c) typ
type abstract_impl
= Functoria.abstract_impl
=
|
Abstract : 'a impl -> abstract_impl
val abstract : 'a impl -> abstract_impl
type key
= Functoria_key.t
type context
= Functoria_key.context
type 'a value
= 'a Functoria_key.value
val if_impl : bool value -> 'a impl -> 'a impl -> 'a impl
val match_impl : 'b value -> default:'a impl -> ('b * 'a impl) list -> 'a impl
module type KEY = sig ... end
type package
= private Functoria.package
=
{
opam : string;
pin : string option;
build : bool;
ocamlfind : Astring.String.Set.t;
min : Astring.String.Set.t;
max : Astring.String.Set.t;
}
val package : ?build:bool -> ?sublibs:string list -> ?ocamlfind:string list -> ?min:string -> ?max:string -> ?pin:string -> string -> package
val foreign : ?packages:package list -> ?keys:key list -> ?deps:abstract_impl list -> string -> 'a typ -> 'a impl
class type !'ty configurable = object ... end
val impl : 'a configurable -> 'a impl
class base_configurable : object ... end
class !'a foreign : ?packages:package list -> ?keys:key list -> ?deps:abstract_impl list -> string -> 'a typ -> 'a configurable
val explode : 'a impl -> [ `App of abstract_impl * abstract_impl | `If of bool value * 'a impl * 'a impl | `Impl of 'a configurable ]
General mirage devices
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.
- parameter size:
size of the ring buffer to use.
Time
Clocks
Log reporters
val default_reporter : ?clock:pclock 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 withclock
. If not provided, the default clock isdefault_posix_clock
.level
is the default log threshold. It isLogs.Info
if not specified.
Random
Consoles
Block devices
Static key/value stores
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
.
val generic_kv_ro : ?group:string -> ?key:[ `Archive | `Crunch | `Direct | `Fat ] value -> string -> kv_ro impl
Generic key/value that will choose dynamically between
fat
,archive
andcrunch
. To use a filesystem implementation, trykv_ro_of_fs
.If no key is provided, it uses
Key.kv_ro
to create a new one.
Filesystem
Network interfaces
val default_network : network impl
default_network
is a dynamic network implementation * which attempts to do something reasonable based on the target.
val netif : ?group:string -> string -> network impl
A custom network interface. Exposes a
Key.interface
key.
Ethernet configuration
ARP configuration
IP configuration
Implementations of the Mirage_types.IP
signature.
type ipv4_config
=
{
network : Ipaddr.V4.Prefix.t;
gateway : Ipaddr.V4.t option;
}
Type for manual IPv4 configuration.
type ipv6_config
=
{
network : Ipaddr.V6.Prefix.t;
gateway : Ipaddr.V6.t option;
}
Type for manual IPv6 configuration.
val create_ipv4 : ?group:string -> ?config:ipv4_config -> ?no_init:bool Key.key -> ?random:random impl -> ?clock:mclock impl -> ethernet impl -> arpv4 impl -> ipv4 impl
Use an IPv4 address Exposes the keys
Key.V4.network
andKey.V4.gateway
. If provided, the values of these keys will override those supplied in the ipv4 configuration record, if that has been provided.
val ipv4_qubes : ?random:random impl -> ?clock:mclock impl -> qubesdb impl -> ethernet impl -> arpv4 impl -> ipv4 impl
Use a given initialized QubesDB to look up and configure the appropriate * IPv4 interface.
UDP configuration
val udpv4 : udpv4 typ
val udpv6 : udpv6 typ
val udpv4v6 : udpv4v6 typ
val direct_udp : ?random:random impl -> 'a ip impl -> 'a udp impl
val socket_udpv4 : ?group:string -> Ipaddr.V4.t option -> udpv4 impl
val socket_udpv6 : ?group:string -> Ipaddr.V6.t option -> udpv6 impl
val socket_udpv4v6 : ?group:string -> Ipaddr.V4.t option -> Ipaddr.V6.t option -> udpv4v6 impl
TCP configuration
val tcpv4 : tcpv4 typ
val tcpv6 : tcpv6 typ
val tcpv4v6 : tcpv4v6 typ
val direct_tcp : ?clock:mclock impl -> ?random:random impl -> ?time:time impl -> 'a ip impl -> 'a tcp impl
val socket_tcpv4 : ?group:string -> Ipaddr.V4.t option -> tcpv4 impl
val socket_tcpv6 : ?group:string -> Ipaddr.V6.t option -> tcpv6 impl
val socket_tcpv4v6 : ?group:string -> Ipaddr.V4.t option -> Ipaddr.V6.t option -> tcpv4v6 impl
Network stack configuration
val direct_stackv4 : ?clock:mclock impl -> ?random:random impl -> ?time:time impl -> ?group:string -> network impl -> ethernet impl -> arpv4 impl -> ipv4 impl -> stackv4 impl
Direct network stack with given ip.
val qubes_ipv4_stack : ?group:string -> ?qubesdb:qubesdb impl -> ?arp:(ethernet impl -> arpv4 impl) -> network impl -> stackv4 impl
Build a stackv4 by looking up configuration information via QubesDB, * building an ipv4, then building a stack on top of that.
val dhcp_ipv4_stack : ?group:string -> ?random:random impl -> ?clock:mclock impl -> ?time:time impl -> ?arp:(ethernet impl -> arpv4 impl) -> network impl -> stackv4 impl
Build a stackv4 by obtaining a DHCP lease, using the lease to * build an ipv4, then building a stack on top of that.
val static_ipv4_stack : ?group:string -> ?config:ipv4_config -> ?arp:(ethernet impl -> arpv4 impl) -> network impl -> stackv4 impl
Build a stackv4 by checking the
Key.V4.network
, andKey.V4.gateway
keys * for ipv4 configuration information, filling in unspecified information from?config
, * then building a stack on top of that.
val generic_stackv4 : ?group:string -> ?config:ipv4_config -> ?dhcp_key:bool value -> ?net_key:[ `Direct | `Socket ] option value -> network impl -> stackv4 impl
Generic stack using a
dhcp
and anet
keys:Key.net
andKey.dhcp
.- If
target
=Qubes
thenqubes_ipv4_stack
is used - Else, if
net
=socket
thensocket_stackv4
is used - Else, if
dhcp
thendhcp_ipv4_stack
is used - Else, if
unix or macosx
thensocket_stackv4
is used - Else,
static_ipv4_stack
is used.
If a key is not provided, it uses
Key.net
orKey.dhcp
(with thegroup
argument) to create it.- If
IPv6
val direct_stackv6 : ?clock:mclock impl -> ?random:random impl -> ?time:time impl -> ?group:string -> network impl -> ethernet impl -> ipv6 impl -> stackv6 impl
Direct network stack with given ip.
val static_ipv6_stack : ?group:string -> ?config:ipv6_config -> network impl -> stackv6 impl
Build a stackv6 by checking the
Key.V6.network
, andKey.V6.gateway
keys for ipv6 configuration information, filling in unspecified information from?config
, then building a stack on top of that.
val generic_stackv6 : ?group:string -> ?config:ipv6_config -> ?net_key:[ `Direct | `Socket ] option value -> network impl -> stackv6 impl
Generic stack using a
net
keys:Key.net
.- If
net
=socket
thensocket_stackv6
is used - Else, if
unix or macosx
thensocket_stackv6
is used - Else,
static_ipv6_stack
is used.
If a key is not provided, it uses
Key.net
(with thegroup
argument) to create it.- If
Dual IPv4 and IPv6
val direct_stackv4v6 : ?clock:mclock impl -> ?random:random impl -> ?time:time impl -> ?group:string -> ipv4_only:bool Key.key -> ipv6_only:bool Key.key -> network impl -> ethernet impl -> arpv4 impl -> ipv4 impl -> ipv6 impl -> stackv4v6 impl
Direct network stack with given ip.
val static_ipv4v6_stack : ?group:string -> ?ipv6_config:ipv6_config -> ?ipv4_config:ipv4_config -> ?arp:(ethernet impl -> arpv4 impl) -> network impl -> stackv4v6 impl
Build a stackv4v6 by checking the
Key.V6.network
, andKey.V6.gateway
keys for IPv4 and IPv6 configuration information, filling in unspecified information from?config
, then building a stack on top of that.
val generic_stackv4v6 : ?group:string -> ?ipv6_config:ipv6_config -> ?ipv4_config:ipv4_config -> ?dhcp_key:bool value -> ?net_key:[ `Direct | `Socket ] option value -> network impl -> stackv4v6 impl
Generic stack using a
net
keys:Key.net
.- If
net
=socket
thensocket_stackv4v6
is used - Else, if
unix or macosx
thensocket_stackv4v6
is used - Else,
static_ipv4v6_stack
is used.
If a key is not provided, it uses
Key.net
(with thegroup
argument) to create it.- If
Resolver configuration
Syslog configuration
type syslog_config
=
{
hostname : string;
server : Ipaddr.t option;
port : int option;
truncate : int option;
}
val syslog_config : ?port:int -> ?truncate:int -> ?server:Ipaddr.t -> string -> syslog_config
Helper for constructing a
syslog_config
.
val syslog_udp : ?config:syslog_config -> ?console:console impl -> ?clock:pclock impl -> stackv4v6 impl -> syslog impl
Emit log messages via UDP to the configured host.
val syslog_tcp : ?config:syslog_config -> ?console:console impl -> ?clock:pclock impl -> stackv4v6 impl -> syslog impl
Emit log messages via TCP to the configured host.
val syslog_tls : ?config:syslog_config -> ?keyname:string -> ?console:console impl -> ?clock:pclock impl -> stackv4v6 impl -> kv_ro impl -> syslog impl
Emit log messages via TLS to the configured host, using the credentials (private ekey, certificate, trust anchor) provided in the KV_RO using the
keyname
.
Entropy
Conduit configuration
HTTP configuration
Argv configuration
val default_argv : Functoria_app.argv impl
default_argv
is a dynamic argv implementation * which attempts to do something reasonable based on the target.
val no_argv : Functoria_app.argv impl
no_argv
Disable command line parsing and set argv to|""|
.
Other devices
type info
info
is the type for module implementingMirage_runtime
.Info.
Application registering
val register : ?argv:Functoria_app.argv impl -> ?tracing:tracing impl -> ?reporter:reporter impl -> ?keys:Key.t list -> ?packages:Functoria.package list -> string -> job impl list -> unit
register name jobs
registers the application named byname
which will executes the givenjobs
.- parameter packages
The opam packages needed by this module.
- parameter keys
The keys related to this module.
- parameter tracing
Enable tracing.
- parameter reporter
Configure logging. The default log reporter is
default_reporter
. To disable logging, useno_reporter
.
- parameter argv
Configure command-line argument parsing. The default parser is
default_argv
. To disable command-line parsing, useno_argv
.