package mirage

  1. Overview
  2. Docs

Configuration library.

Mirage_types defines a set of well-defined module signatures which are used by the various mirage libraries to implement a large collection of devices.

Module combinators

type 'a typ

The type of values representing module types.

val (@->) : 'a typ -> 'b typ -> ('a -> 'b) typ

Construct a functor type from a type and an existing functor type. This corresponds to prepending a parameter to the list of functor parameters. For example,

kv_ro @-> ip @-> kv_ro 

describes a functor type that accepts two arguments -- a kv_ro and an ip device -- and returns a kv_ro.

type 'a impl

The type of values representing module implementations.

val ($) : ('a -> 'b) impl -> 'a impl -> 'b impl

m $ a applies the functor a to the functor m.

val foreign : string -> ?libraries:string list -> ?packages:string list -> 'a typ -> 'a impl

foreign name libs packs constr typ states that the module named by name has the module type typ. If libs is set, add the given set of ocamlfind libraries to the ones loaded by default. If packages is set, add the given set of OPAM packages to the ones loaded by default.

val typ : 'a impl -> 'a typ

Return the module signature of a given implementation.

Time

type time

Abstract type for timers.

val time : time typ

The V1.TIME module signature.

val default_time : time impl

The default timer implementation.

Clocks

type clock

Abstract type for clocks.

val clock : clock typ

The V1.CLOCK module signature.

val default_clock : clock impl

The default mirage-clock implementation.

Random

type random

Abstract type for random sources.

val random : random typ

The V1.RANDOM module signature.

val default_random : random impl

Passthrough to the OCaml Random generator.

Consoles

Implementations of the V1.CONSOLE signature.

type console

Abstract type for consoles.

val console : console typ

The V1.CONSOLE module 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

The V1.IO_PAGE module signature.

val default_io_page : io_page impl

The default Io_page implementation.

Block devices

Implementations of the V1.BLOCK signature.

type block

Abstract type for raw block device configurations.

val block : block typ

The V1.BLOCK module signature.

val block_of_file : string -> block impl

Use the given filen as a raw block device.

Static key/value stores

Implementations of the V1.KV_RO signature.

type kv_ro

Abstract type for read-only key/value store.

val kv_ro : kv_ro typ

The V1.KV_RO module signature.

val crunch : string -> kv_ro impl

Crunch a directory.

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

Implementations of the V1.FS signature.

type fs

Abstract type for filesystems.

val fs : fs typ

The V1.FS module 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.

Network interfaces

Implementations of the V1.NETWORK signature.

type network

Abstract type for network configurations.

val network : network typ

Representation of Mirage_types.NETWORK.

val tap0 : network impl

The '/dev/tap0' interface.

val netif : string -> network impl

A custom network interface.

Ethernet configuration

type ethernet

Implementations of the V1.ETHIF signature.

val ethernet : ethernet typ
val etif : network impl -> ethernet impl

IP configuration

Implementations of the V1.IP signature.

type v4
type v6
type 'a ip
type ipv4 = v4 ip
type ipv6 = v6 ip

Abstract type for IP configurations.

val ipv4 : ipv4 typ

The V1.IPV4 module signature.

val ipv6 : ipv6 typ

The V1.IPV6 module signature.

type ('ipaddr, 'prefix) ip_config = {
  1. address : 'ipaddr;
  2. netmask : 'prefix;
  3. 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 -> network impl -> ipv4_config -> ipv4 impl

Use an IPv4 address.

val default_ipv4 : network impl -> ipv4 impl

Default local IP listening on the given network interfaces:

  • address: 10.0.0.2
  • netmask: 255.255.255.0
  • gateways: 10.0.0.1
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 -> network impl -> ipv6_config -> ipv6 impl

Use an IPv6 address.

UDP configuration

Implementation of the V1.UDP signature.

type 'a udp
type udpv4 = v4 udp
type udpv6 = v6 udp
val udp : 'a udp typ
val udpv4 : udpv4 typ
val udpv6 : udpv6 typ
val direct_udp : 'a ip impl -> 'a udp impl
val socket_udpv4 : Ipaddr.V4.t option -> udpv4 impl

TCP configuration

Implementation of the V1.TCP signature.

type 'a tcp
type tcpv4 = v4 tcp
type tcpv6 = v6 tcp
val tcp : 'a tcp typ
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 : Ipaddr.V4.t option -> tcpv4 impl

Network stack configuration

Implementation of the V1.STACKV4 signature.

type stackv4
val stackv4 : stackv4 typ
val direct_stackv4_with_default_ipv4 : ?clock:clock impl -> ?random:random impl -> ?time:time impl -> console impl -> network impl -> stackv4 impl
val direct_stackv4_with_static_ipv4 : ?clock:clock impl -> ?random:random impl -> ?time:time impl -> console impl -> network impl -> ipv4_config -> stackv4 impl
val direct_stackv4_with_dhcp : ?clock:clock impl -> ?random:random impl -> ?time:time impl -> console impl -> network impl -> stackv4 impl
val socket_stackv4 : console impl -> Ipaddr.V4.t list -> stackv4 impl

esolver configuration

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

Vchan configuration

val vchan : vchan typ
val vchan_localhost : ?uuid:string -> unit -> vchan impl
val vchan_xen : ?uuid:string -> unit -> vchan impl
val vchan_default : ?uuid:string -> unit -> vchan impl
type conduit_tls

TLS configuration

onduit configuration

type conduit
val conduit : conduit typ
val conduit_direct : ?vchan:vchan impl -> ?tls:conduit_tls impl -> stackv4 impl -> conduit impl
type conduit_client = [
  1. | `TCP of Ipaddr.t * int
  2. | `Vchan of string list
]
type conduit_server = [
  1. | `TCP of [ `Port of int ]
  2. | `Vchan of string list
]

HTTP configuration

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

Tracing

type tracing
val mprof_trace : size:int -> unit -> tracing

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.

Jobs

type job

Type for job values.

val job : job typ

Reprensention of JOB.

val register : ?tracing:tracing -> string -> job impl list -> unit

register name jobs registers the application named by name which will executes the given jobs.

  • parameter tracing

    enables tracing if present (see mprof_trace).

type t = {
  1. name : string;
  2. root : string;
  3. jobs : job impl list;
  4. tracing : tracing option;
}

Type for values representing a project description.

val load : string option -> t

Read a config file. If no name is given, search for use config.ml.

Device configuration

type mode = [
  1. | `Unix
  2. | `Xen
  3. | `MacOSX
]

Configuration mode.

val set_mode : mode -> unit

Set the configuration mode for the current project.

val get_mode : unit -> mode
module Impl : sig ... end

Configurable device.

Project configuration

val manage_opam_packages : bool -> unit

Tell Irminsule to manage the OPAM configuration (ie. install/remove missing packages).

val no_opam_version_check : bool -> unit

Bypass the check of opam's version.

val add_to_opam_packages : string list -> unit

Add some base OPAM package to install

val add_to_ocamlfind_libraries : string list -> unit

Link with the provided additional libraries.

val packages : t -> string list

List of OPAM packages to install for this project.

val libraries : t -> string list

List of ocamlfind libraries.

val configure : t -> unit

Generate some code to create a value with the right configuration settings.

val clean : t -> unit

Remove all the autogen files.

val build : t -> unit

Call make build in the right directory.

Extensions

module type CONFIGURABLE = sig ... end

Signature for configurable devices.

val implementation : 'a -> 'b -> (module CONFIGURABLE with type t = 'b) -> 'a impl

Extend the library with an external configuration.

val append_main : ('a, unit, string, unit) Stdlib.format4 -> 'a

Add some string to main.ml.

val newline_main : unit -> unit

Add a newline to main.ml.

Implementation of IO page allocators.

Implementation of clocks.

Implementation of timers.

Implementation of timers.

Implementation of consoles.

Implementation of crunch a local filesystem.

Implementation of direct access to the filesystem as a key/value read-only store.

Implementation of raw block device.

module Fat : CONFIGURABLE

Implementatin of the Fat filesystem.

Implementation of network configuration.

Signature for configurable devices.

Signature for configurable devices.

Signature for configurable devices.

module UDP_direct (V : sig ... end) : CONFIGURABLE

Signature for configurable devices.

Signature for configurable devices.

module TCP_direct (V : sig ... end) : CONFIGURABLE

Signature for configurable devices.

Signature for configurable devices.

Signature for configurable devices.

Signature for configurable devices.

Signature for configurable devices.

module Job : CONFIGURABLE

Signature for configurable devices.

Generation of fresh names

module Name : sig ... end
OCaml

Innovation. Community. Security.