(* OCaml bindings for libvirt.
(C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
http://libvirt.org/
- $Id: libvirt.ml,v 1.2 2007/08/21 13:24:08 rjones Exp $
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
type uuid = string
type xml = string
+type filename = string
+
external get_version : ?driver:string -> unit -> int * int = "ocaml_libvirt_get_version"
let uuid_length = 16
external get_max_vcpus : [>`R] t -> ?type_:string -> unit -> int = "ocaml_libvirt_connect_get_max_vcpus"
external list_domains : [>`R] t -> int -> int array = "ocaml_libvirt_connect_list_domains"
external num_of_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_domains"
- external get_capabilities : [>`R] t -> string = "ocaml_libvirt_connect_get_capabilities"
+ external get_capabilities : [>`R] t -> xml = "ocaml_libvirt_connect_get_capabilities"
external num_of_defined_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_domains"
external list_defined_domains : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_domains"
external num_of_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_networks"
external num_of_defined_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_networks"
external list_defined_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_networks"
external get_node_info : [>`R] t -> node_info = "ocaml_libvirt_connect_get_node_info"
+ external node_get_free_memory : [> `R] t -> int64 = "ocaml_libvirt_connect_node_get_free_memory"
+ external node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array = "ocaml_libvirt_connect_node_get_cells_free_memory"
(* See VIR_NODEINFO_MAXCPUS macro defined in <libvirt.h>. *)
let maxcpus_of_node_info { nodes = nodes; sockets = sockets;
external free : [>`R] t -> unit = "ocaml_libvirt_domain_free"
external suspend : [>`W] t -> unit = "ocaml_libvirt_domain_suspend"
external resume : [>`W] t -> unit = "ocaml_libvirt_domain_resume"
- external save : [>`W] t -> string -> unit = "ocaml_libvirt_domain_save"
- external restore : [>`W] Connect.t -> string -> unit = "ocaml_libvirt_domain_restore"
- external core_dump : [>`W] t -> string -> unit = "ocaml_libvirt_domain_core_dump"
+ external save : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_save"
+ external restore : [>`W] Connect.t -> filename -> unit = "ocaml_libvirt_domain_restore"
+ external core_dump : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_core_dump"
external shutdown : [>`W] t -> unit = "ocaml_libvirt_domain_shutdown"
external reboot : [>`W] t -> unit = "ocaml_libvirt_domain_reboot"
external get_name : [>`R] t -> string = "ocaml_libvirt_domain_get_name"
| VIR_WAR_NO_NETWORK
| VIR_ERR_NO_DOMAIN
| VIR_ERR_NO_NETWORK
+ | VIR_ERR_INVALID_MAC
+ | VIR_ERR_UNKNOWN of int
let string_of_code = function
| VIR_ERR_OK -> "VIR_ERR_OK"
| VIR_WAR_NO_NETWORK -> "VIR_WAR_NO_NETWORK"
| VIR_ERR_NO_DOMAIN -> "VIR_ERR_NO_DOMAIN"
| VIR_ERR_NO_NETWORK -> "VIR_ERR_NO_NETWORK"
-
- type level =
- | VIR_ERR_NONE
- | VIR_ERR_WARNING
- | VIR_ERR_ERROR
-
- let string_of_level = function
- | VIR_ERR_NONE -> "VIR_ERR_NONE"
- | VIR_ERR_WARNING -> "VIR_ERR_WARNING"
- | VIR_ERR_ERROR -> "VIR_ERR_ERROR"
+ | VIR_ERR_INVALID_MAC -> "VIR_ERR_INVALID_MAC"
+ | VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i
type domain =
| VIR_FROM_NONE
| VIR_FROM_NET
| VIR_FROM_TEST
| VIR_FROM_REMOTE
+ | VIR_FROM_OPENVZ
+ | VIR_FROM_XENXM
+ | VIR_FROM_STATS_LINUX
+ | VIR_FROM_UNKNOWN of int
let string_of_domain = function
| VIR_FROM_NONE -> "VIR_FROM_NONE"
| VIR_FROM_NET -> "VIR_FROM_NET"
| VIR_FROM_TEST -> "VIR_FROM_TEST"
| VIR_FROM_REMOTE -> "VIR_FROM_REMOTE"
+ | VIR_FROM_OPENVZ -> "VIR_FROM_OPENVZ"
+ | VIR_FROM_XENXM -> "VIR_FROM_XENXM"
+ | VIR_FROM_STATS_LINUX -> "VIR_FROM_STATS_LINUX"
+ | VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i
+
+ type level =
+ | VIR_ERR_NONE
+ | VIR_ERR_WARNING
+ | VIR_ERR_ERROR
+ | VIR_ERR_UNKNOWN_LEVEL of int
+
+ let string_of_level = function
+ | VIR_ERR_NONE -> "VIR_ERR_NONE"
+ | VIR_ERR_WARNING -> "VIR_ERR_WARNING"
+ | VIR_ERR_ERROR -> "VIR_ERR_ERROR"
+ | VIR_ERR_UNKNOWN_LEVEL i -> "VIR_ERR_LEVEL_" ^ string_of_int i
type t = {
code : code;
end
exception Virterror of Virterror.t
+exception Not_supported of string
(* Initialization. *)
external c_init : unit -> unit = "ocaml_libvirt_init"
let () =
Callback.register_exception
"ocaml_libvirt_virterror" (Virterror (Virterror.no_error ()));
+ Callback.register_exception
+ "ocaml_libvirt_not_supported" (Not_supported "");
c_init ()