Module Libvirt.Connect


module Connect: sig .. end
Module dealing with connections. Connect.t is the connection object.

type 'a t 
Connection. Read-only connections have type ro Connect.t and read-write connections have type rw Connect.t.

type node_info = {
   model : string; (*CPU model*)
   memory : int64; (*memory size in kilobytes*)
   cpus : int; (*number of active CPUs*)
   mhz : int; (*expected CPU frequency*)
   nodes : int; (*number of NUMA nodes (1 = UMA)*)
   sockets : int; (*number of CPU sockets per node*)
   cores : int; (*number of cores per socket*)
   threads : int; (*number of threads per core*)
}
val connect : ?name:string -> unit -> Libvirt.rw t
val connect_readonly : ?name:string -> unit -> Libvirt.ro t
connect ~name () connects to the hypervisor with URI name.

connect () connects to the default hypervisor.

connect_readonly is the same but connects in read-only mode.

val close : [> `R ] t -> unit
close conn closes and frees the connection object in memory.

The connection is automatically closed if it is garbage collected. This function just forces it to be closed and freed right away.

val get_type : [> `R ] t -> string
Returns the name of the driver (hypervisor).
val get_version : [> `R ] t -> int
Returns the driver version major * 1_000_000 + minor * 1000 + release
val get_hostname : [> `R ] t -> string
Returns the hostname of the physical server.
val get_uri : [> `R ] t -> string
Returns the canonical connection URI.
val get_max_vcpus : [> `R ] t -> ?type_:string -> unit -> int
Returns the maximum number of virtual CPUs supported by a guest VM of a particular type.
val list_domains : [> `R ] t -> int -> int array
list_domains conn max returns the running domain IDs, up to a maximum of max entries.

Call Libvirt.Connect.num_of_domains first to get a value for max.

See also: Libvirt.Domain.get_domains, Libvirt.Domain.get_domains_and_infos.

val num_of_domains : [> `R ] t -> int
Returns the number of running domains.
val get_capabilities : [> `R ] t -> Libvirt.xml
Returns the hypervisor capabilities (as XML).
val num_of_defined_domains : [> `R ] t -> int
Returns the number of inactive (shutdown) domains.
val list_defined_domains : [> `R ] t -> int -> string array
list_defined_domains conn max returns the names of the inactive domains, up to a maximum of max entries.

Call Libvirt.Connect.num_of_defined_domains first to get a value for max.

See also: Libvirt.Domain.get_domains, Libvirt.Domain.get_domains_and_infos.

val num_of_networks : [> `R ] t -> int
Returns the number of networks.
val list_networks : [> `R ] t -> int -> string array
list_networks conn max returns the names of the networks, up to a maximum of max entries. Call Libvirt.Connect.num_of_networks first to get a value for max.
val num_of_defined_networks : [> `R ] t -> int
Returns the number of inactive networks.
val list_defined_networks : [> `R ] t -> int -> string array
list_defined_networks conn max returns the names of the inactive networks, up to a maximum of max entries. Call Libvirt.Connect.num_of_defined_networks first to get a value for max.
val num_of_pools : [> `R ] t -> int
Returns the number of storage pools.
val list_pools : [> `R ] t -> int -> string array
Return list of storage pools.
val num_of_defined_pools : [> `R ] t -> int
Returns the number of storage pools.
val list_defined_pools : [> `R ] t -> int -> string array
Return list of storage pools.
val get_node_info : [> `R ] t -> node_info
Return information about the physical server.
val node_get_free_memory : [> `R ] t -> int64
node_get_free_memory conn returns the amount of free memory (not allocated to any guest) in the machine.
val node_get_cells_free_memory : [> `R ] t -> int -> int -> int64 array
node_get_cells_free_memory conn start max returns the amount of free memory on each NUMA cell in kilobytes. start is the first cell for which we return free memory. max is the maximum number of cells for which we return free memory. Returns an array of up to max entries in length.
val maxcpus_of_node_info : node_info -> int
Calculate the total number of CPUs supported (but not necessarily active) in the host.
val cpumaplen : int -> int
Calculate the length (in bytes) required to store the complete CPU map between a single virtual and all physical CPUs of a domain.
val use_cpu : string -> int -> unit
use_cpu cpumap cpu marks cpu as usable in cpumap.
val unuse_cpu : string -> int -> unit
unuse_cpu cpumap cpu marks cpu as not usable in cpumap.
val cpu_usable : string -> int -> int -> int -> bool
cpu_usable cpumaps maplen vcpu cpu checks returns true iff the cpu is usable by vcpu.
val const : [> `R ] t -> Libvirt.ro t
const conn turns a read/write connection into a read-only connection. Note that the opposite operation is impossible.