1 (* OCaml bindings for libvirt.
2 (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version,
9 with the OCaml linking exception described in ../COPYING.LIB.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 type filename = string
27 external get_version : ?driver:string -> unit -> int * int = "ocaml_libvirt_get_version"
30 let uuid_string_length = 36
32 (* http://caml.inria.fr/pub/ml-archives/caml-list/2004/07/80683af867cce6bf8fff273973f70c95.en.html *)
52 | ListNoState | ListRunning | ListBlocked
53 | ListPaused | ListShutdown | ListShutoff | ListCrashed
58 external connect : ?name:string -> unit -> rw t = "ocaml_libvirt_connect_open"
59 external connect_readonly : ?name:string -> unit -> ro t = "ocaml_libvirt_connect_open_readonly"
60 external close : [>`R] t -> unit = "ocaml_libvirt_connect_close"
61 external get_type : [>`R] t -> string = "ocaml_libvirt_connect_get_type"
62 external get_version : [>`R] t -> int = "ocaml_libvirt_connect_get_version"
63 external get_hostname : [>`R] t -> string = "ocaml_libvirt_connect_get_hostname"
64 external get_uri : [>`R] t -> string = "ocaml_libvirt_connect_get_uri"
65 external get_max_vcpus : [>`R] t -> ?type_:string -> unit -> int = "ocaml_libvirt_connect_get_max_vcpus"
66 external list_domains : [>`R] t -> int -> int array = "ocaml_libvirt_connect_list_domains"
67 external num_of_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_domains"
68 external get_capabilities : [>`R] t -> xml = "ocaml_libvirt_connect_get_capabilities"
69 external num_of_defined_domains : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_domains"
70 external list_defined_domains : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_domains"
71 external num_of_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_networks"
72 external list_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_networks"
73 external num_of_defined_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_networks"
74 external list_defined_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_networks"
75 external num_of_pools : [>`R] t -> int = "ocaml_libvirt_connect_num_of_storage_pools"
76 external list_pools : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_storage_pools"
77 external num_of_defined_pools : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_storage_pools"
78 external list_defined_pools : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_storage_pools"
80 external get_node_info : [>`R] t -> node_info = "ocaml_libvirt_connect_get_node_info"
81 external node_get_free_memory : [> `R] t -> int64 = "ocaml_libvirt_connect_node_get_free_memory"
82 external node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array = "ocaml_libvirt_connect_node_get_cells_free_memory"
84 (* See VIR_NODEINFO_MAXCPUS macro defined in <libvirt.h>. *)
85 let maxcpus_of_node_info { nodes = nodes; sockets = sockets;
86 cores = cores; threads = threads } =
87 nodes * sockets * cores * threads
89 (* See VIR_CPU_MAPLEN macro defined in <libvirt.h>. *)
90 let cpumaplen nr_cpus =
93 (* See VIR_USE_CPU, VIR_UNUSE_CPU, VIR_CPU_USABLE macros defined in <libvirt.h>. *)
94 let use_cpu cpumap cpu =
96 Char.chr (Char.code cpumap.[cpu/8] lor (1 lsl (cpu mod 8)))
97 let unuse_cpu cpumap cpu =
99 Char.chr (Char.code cpumap.[cpu/8] land (lnot (1 lsl (cpu mod 8))))
100 let cpu_usable cpumaps maplen vcpu cpu =
101 Char.code cpumaps.[vcpu*maplen + cpu/8] land (1 lsl (cpu mod 8)) <> 0
103 external set_keep_alive : [>`R] t -> int -> int -> unit = "ocaml_libvirt_connect_set_keep_alive"
105 external const : [>`R] t -> ro t = "%identity"
112 | VIR_ERR_INTERNAL_ERROR
115 | VIR_ERR_UNKNOWN_HOST
117 | VIR_ERR_INVALID_CONN
118 | VIR_ERR_INVALID_DOMAIN
119 | VIR_ERR_INVALID_ARG
120 | VIR_ERR_OPERATION_FAILED
122 | VIR_ERR_POST_FAILED
124 | VIR_ERR_SEXPR_SERIAL
135 | VIR_ERR_NO_XENSTORE
136 | VIR_ERR_DRIVER_FULL
137 | VIR_ERR_CALL_FAILED
140 | VIR_ERR_OPERATION_DENIED
141 | VIR_ERR_OPEN_FAILED
142 | VIR_ERR_READ_FAILED
143 | VIR_ERR_PARSE_FAILED
144 | VIR_ERR_CONF_SYNTAX
145 | VIR_ERR_WRITE_FAILED
147 | VIR_ERR_INVALID_NETWORK
148 | VIR_ERR_NETWORK_EXIST
149 | VIR_ERR_SYSTEM_ERROR
151 | VIR_ERR_GNUTLS_ERROR
155 | VIR_ERR_INVALID_MAC
156 | VIR_ERR_AUTH_FAILED
157 | VIR_ERR_INVALID_STORAGE_POOL
158 | VIR_ERR_INVALID_STORAGE_VOL
160 | VIR_ERR_NO_STORAGE_POOL
161 | VIR_ERR_NO_STORAGE_VOL
162 | VIR_ERR_UNKNOWN of int
164 let string_of_code = function
165 | VIR_ERR_OK -> "VIR_ERR_OK"
166 | VIR_ERR_INTERNAL_ERROR -> "VIR_ERR_INTERNAL_ERROR"
167 | VIR_ERR_NO_MEMORY -> "VIR_ERR_NO_MEMORY"
168 | VIR_ERR_NO_SUPPORT -> "VIR_ERR_NO_SUPPORT"
169 | VIR_ERR_UNKNOWN_HOST -> "VIR_ERR_UNKNOWN_HOST"
170 | VIR_ERR_NO_CONNECT -> "VIR_ERR_NO_CONNECT"
171 | VIR_ERR_INVALID_CONN -> "VIR_ERR_INVALID_CONN"
172 | VIR_ERR_INVALID_DOMAIN -> "VIR_ERR_INVALID_DOMAIN"
173 | VIR_ERR_INVALID_ARG -> "VIR_ERR_INVALID_ARG"
174 | VIR_ERR_OPERATION_FAILED -> "VIR_ERR_OPERATION_FAILED"
175 | VIR_ERR_GET_FAILED -> "VIR_ERR_GET_FAILED"
176 | VIR_ERR_POST_FAILED -> "VIR_ERR_POST_FAILED"
177 | VIR_ERR_HTTP_ERROR -> "VIR_ERR_HTTP_ERROR"
178 | VIR_ERR_SEXPR_SERIAL -> "VIR_ERR_SEXPR_SERIAL"
179 | VIR_ERR_NO_XEN -> "VIR_ERR_NO_XEN"
180 | VIR_ERR_XEN_CALL -> "VIR_ERR_XEN_CALL"
181 | VIR_ERR_OS_TYPE -> "VIR_ERR_OS_TYPE"
182 | VIR_ERR_NO_KERNEL -> "VIR_ERR_NO_KERNEL"
183 | VIR_ERR_NO_ROOT -> "VIR_ERR_NO_ROOT"
184 | VIR_ERR_NO_SOURCE -> "VIR_ERR_NO_SOURCE"
185 | VIR_ERR_NO_TARGET -> "VIR_ERR_NO_TARGET"
186 | VIR_ERR_NO_NAME -> "VIR_ERR_NO_NAME"
187 | VIR_ERR_NO_OS -> "VIR_ERR_NO_OS"
188 | VIR_ERR_NO_DEVICE -> "VIR_ERR_NO_DEVICE"
189 | VIR_ERR_NO_XENSTORE -> "VIR_ERR_NO_XENSTORE"
190 | VIR_ERR_DRIVER_FULL -> "VIR_ERR_DRIVER_FULL"
191 | VIR_ERR_CALL_FAILED -> "VIR_ERR_CALL_FAILED"
192 | VIR_ERR_XML_ERROR -> "VIR_ERR_XML_ERROR"
193 | VIR_ERR_DOM_EXIST -> "VIR_ERR_DOM_EXIST"
194 | VIR_ERR_OPERATION_DENIED -> "VIR_ERR_OPERATION_DENIED"
195 | VIR_ERR_OPEN_FAILED -> "VIR_ERR_OPEN_FAILED"
196 | VIR_ERR_READ_FAILED -> "VIR_ERR_READ_FAILED"
197 | VIR_ERR_PARSE_FAILED -> "VIR_ERR_PARSE_FAILED"
198 | VIR_ERR_CONF_SYNTAX -> "VIR_ERR_CONF_SYNTAX"
199 | VIR_ERR_WRITE_FAILED -> "VIR_ERR_WRITE_FAILED"
200 | VIR_ERR_XML_DETAIL -> "VIR_ERR_XML_DETAIL"
201 | VIR_ERR_INVALID_NETWORK -> "VIR_ERR_INVALID_NETWORK"
202 | VIR_ERR_NETWORK_EXIST -> "VIR_ERR_NETWORK_EXIST"
203 | VIR_ERR_SYSTEM_ERROR -> "VIR_ERR_SYSTEM_ERROR"
204 | VIR_ERR_RPC -> "VIR_ERR_RPC"
205 | VIR_ERR_GNUTLS_ERROR -> "VIR_ERR_GNUTLS_ERROR"
206 | VIR_WAR_NO_NETWORK -> "VIR_WAR_NO_NETWORK"
207 | VIR_ERR_NO_DOMAIN -> "VIR_ERR_NO_DOMAIN"
208 | VIR_ERR_NO_NETWORK -> "VIR_ERR_NO_NETWORK"
209 | VIR_ERR_INVALID_MAC -> "VIR_ERR_INVALID_MAC"
210 | VIR_ERR_AUTH_FAILED -> "VIR_ERR_AUTH_FAILED"
211 | VIR_ERR_INVALID_STORAGE_POOL -> "VIR_ERR_INVALID_STORAGE_POOL"
212 | VIR_ERR_INVALID_STORAGE_VOL -> "VIR_ERR_INVALID_STORAGE_VOL"
213 | VIR_WAR_NO_STORAGE -> "VIR_WAR_NO_STORAGE"
214 | VIR_ERR_NO_STORAGE_POOL -> "VIR_ERR_NO_STORAGE_POOL"
215 | VIR_ERR_NO_STORAGE_VOL -> "VIR_ERR_NO_STORAGE_VOL"
216 | VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i
235 | VIR_FROM_STATS_LINUX
237 | VIR_FROM_UNKNOWN of int
239 let string_of_domain = function
240 | VIR_FROM_NONE -> "VIR_FROM_NONE"
241 | VIR_FROM_XEN -> "VIR_FROM_XEN"
242 | VIR_FROM_XEND -> "VIR_FROM_XEND"
243 | VIR_FROM_XENSTORE -> "VIR_FROM_XENSTORE"
244 | VIR_FROM_SEXPR -> "VIR_FROM_SEXPR"
245 | VIR_FROM_XML -> "VIR_FROM_XML"
246 | VIR_FROM_DOM -> "VIR_FROM_DOM"
247 | VIR_FROM_RPC -> "VIR_FROM_RPC"
248 | VIR_FROM_PROXY -> "VIR_FROM_PROXY"
249 | VIR_FROM_CONF -> "VIR_FROM_CONF"
250 | VIR_FROM_QEMU -> "VIR_FROM_QEMU"
251 | VIR_FROM_NET -> "VIR_FROM_NET"
252 | VIR_FROM_TEST -> "VIR_FROM_TEST"
253 | VIR_FROM_REMOTE -> "VIR_FROM_REMOTE"
254 | VIR_FROM_OPENVZ -> "VIR_FROM_OPENVZ"
255 | VIR_FROM_XENXM -> "VIR_FROM_XENXM"
256 | VIR_FROM_STATS_LINUX -> "VIR_FROM_STATS_LINUX"
257 | VIR_FROM_STORAGE -> "VIR_FROM_STORAGE"
258 | VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i
264 | VIR_ERR_UNKNOWN_LEVEL of int
266 let string_of_level = function
267 | VIR_ERR_NONE -> "VIR_ERR_NONE"
268 | VIR_ERR_WARNING -> "VIR_ERR_WARNING"
269 | VIR_ERR_ERROR -> "VIR_ERR_ERROR"
270 | VIR_ERR_UNKNOWN_LEVEL i -> "VIR_ERR_LEVEL_" ^ string_of_int i
275 message : string option;
277 str1 : string option;
278 str2 : string option;
279 str3 : string option;
284 let to_string { code = code; domain = domain; message = message } =
285 let buf = Buffer.create 128 in
286 Buffer.add_string buf "libvirt: ";
287 Buffer.add_string buf (string_of_code code);
288 Buffer.add_string buf ": ";
289 Buffer.add_string buf (string_of_domain domain);
290 Buffer.add_string buf ": ";
291 (match message with Some msg -> Buffer.add_string buf msg | None -> ());
294 external get_last_error : unit -> t option = "ocaml_libvirt_virterror_get_last_error"
295 external get_last_conn_error : [>`R] Connect.t -> t option = "ocaml_libvirt_virterror_get_last_conn_error"
296 external reset_last_error : unit -> unit = "ocaml_libvirt_virterror_reset_last_error"
297 external reset_last_conn_error : [>`R] Connect.t -> unit = "ocaml_libvirt_virterror_reset_last_conn_error"
300 { code = VIR_ERR_OK; domain = VIR_FROM_NONE;
301 message = None; level = VIR_ERR_NONE;
302 str1 = None; str2 = None; str3 = None;
303 int1 = 0_l; int2 = 0_l }
306 exception Virterror of Virterror.t
307 exception Not_supported of string
309 let rec map_ignore_errors f = function
312 try f x :: map_ignore_errors f xs
313 with Virterror _ -> map_ignore_errors f xs
320 | InfoNoState | InfoRunning | InfoBlocked | InfoPaused
321 | InfoShutdown | InfoShutoff | InfoCrashed
331 type vcpu_state = VcpuOffline | VcpuRunning | VcpuBlocked
335 vcpu_state : vcpu_state;
340 type sched_param = string * sched_param_value
341 and sched_param_value =
342 | SchedFieldInt32 of int32 | SchedFieldUInt32 of int32
343 | SchedFieldInt64 of int64 | SchedFieldUInt64 of int64
344 | SchedFieldFloat of float | SchedFieldBool of bool
346 type typed_param = string * typed_param_value
347 and typed_param_value =
348 | TypedFieldInt32 of int32 | TypedFieldUInt32 of int32
349 | TypedFieldInt64 of int64 | TypedFieldUInt64 of int64
350 | TypedFieldFloat of float | TypedFieldBool of bool
351 | TypedFieldString of string
353 type migrate_flag = Live
355 type memory_flag = Virtual
370 type interface_stats = {
381 (* The maximum size for Domain.memory_peek and Domain.block_peek
382 * supported by libvirt. This may change with different versions
383 * of libvirt in the future, hence it's a function.
385 let max_peek _ = 65536
387 external create_linux : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_domain_create_linux"
388 external lookup_by_id : 'a Connect.t -> int -> 'a t = "ocaml_libvirt_domain_lookup_by_id"
389 external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid"
390 external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid_string"
391 external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_domain_lookup_by_name"
392 external destroy : [>`W] t -> unit = "ocaml_libvirt_domain_destroy"
393 external free : [>`R] t -> unit = "ocaml_libvirt_domain_free"
394 external suspend : [>`W] t -> unit = "ocaml_libvirt_domain_suspend"
395 external resume : [>`W] t -> unit = "ocaml_libvirt_domain_resume"
396 external save : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_save"
397 external restore : [>`W] Connect.t -> filename -> unit = "ocaml_libvirt_domain_restore"
398 external core_dump : [>`W] t -> filename -> unit = "ocaml_libvirt_domain_core_dump"
399 external shutdown : [>`W] t -> unit = "ocaml_libvirt_domain_shutdown"
400 external reboot : [>`W] t -> unit = "ocaml_libvirt_domain_reboot"
401 external get_name : [>`R] t -> string = "ocaml_libvirt_domain_get_name"
402 external get_uuid : [>`R] t -> uuid = "ocaml_libvirt_domain_get_uuid"
403 external get_uuid_string : [>`R] t -> string = "ocaml_libvirt_domain_get_uuid_string"
404 external get_id : [>`R] t -> int = "ocaml_libvirt_domain_get_id"
405 external get_os_type : [>`R] t -> string = "ocaml_libvirt_domain_get_os_type"
406 external get_max_memory : [>`R] t -> int64 = "ocaml_libvirt_domain_get_max_memory"
407 external set_max_memory : [>`W] t -> int64 -> unit = "ocaml_libvirt_domain_set_max_memory"
408 external set_memory : [>`W] t -> int64 -> unit = "ocaml_libvirt_domain_set_memory"
409 external get_info : [>`R] t -> info = "ocaml_libvirt_domain_get_info"
410 external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_domain_get_xml_desc"
411 external get_scheduler_type : [>`R] t -> string * int = "ocaml_libvirt_domain_get_scheduler_type"
412 external get_scheduler_parameters : [>`R] t -> int -> sched_param array = "ocaml_libvirt_domain_get_scheduler_parameters"
413 external set_scheduler_parameters : [>`W] t -> sched_param array -> unit = "ocaml_libvirt_domain_set_scheduler_parameters"
414 external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_domain_define_xml"
415 external undefine : [>`W] t -> unit = "ocaml_libvirt_domain_undefine"
416 external create : [>`W] t -> unit = "ocaml_libvirt_domain_create"
417 external get_autostart : [>`R] t -> bool = "ocaml_libvirt_domain_get_autostart"
418 external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_domain_set_autostart"
419 external set_vcpus : [>`W] t -> int -> unit = "ocaml_libvirt_domain_set_vcpus"
420 external pin_vcpu : [>`W] t -> int -> string -> unit = "ocaml_libvirt_domain_pin_vcpu"
421 external get_vcpus : [>`R] t -> int -> int -> int * vcpu_info array * string = "ocaml_libvirt_domain_get_vcpus"
422 external get_cpu_stats : [>`R] t -> typed_param list array = "ocaml_libvirt_domain_get_cpu_stats"
423 external get_max_vcpus : [>`R] t -> int = "ocaml_libvirt_domain_get_max_vcpus"
424 external attach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_attach_device"
425 external detach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_detach_device"
426 external migrate : [>`W] t -> [>`W] Connect.t -> migrate_flag list -> ?dname:string -> ?uri:string -> ?bandwidth:int -> unit -> rw t = "ocaml_libvirt_domain_migrate_bytecode" "ocaml_libvirt_domain_migrate_native"
427 external block_stats : [>`R] t -> string -> block_stats = "ocaml_libvirt_domain_block_stats"
428 external interface_stats : [>`R] t -> string -> interface_stats = "ocaml_libvirt_domain_interface_stats"
429 external block_peek : [>`W] t -> string -> int64 -> int -> string -> int -> unit = "ocaml_libvirt_domain_block_peek_bytecode" "ocaml_libvirt_domain_block_peek_native"
430 external memory_peek : [>`W] t -> memory_flag list -> int64 -> int -> string -> int -> unit = "ocaml_libvirt_domain_memory_peek_bytecode" "ocaml_libvirt_domain_memory_peek_native"
432 external const : [>`R] t -> ro t = "%identity"
434 let get_domains conn flags =
435 (* Old/slow/inefficient method. *)
436 let get_active, get_inactive =
437 if List.mem ListAll flags then
440 (List.mem ListActive flags, List.mem ListInactive flags) in
443 let n = Connect.num_of_domains conn in
444 let ids = Connect.list_domains conn n in
445 let ids = Array.to_list ids in
446 map_ignore_errors (lookup_by_id conn) ids
450 if get_inactive then (
451 let n = Connect.num_of_defined_domains conn in
452 let names = Connect.list_defined_domains conn n in
453 let names = Array.to_list names in
454 map_ignore_errors (lookup_by_name conn) names
457 active_doms @ inactive_doms
459 let get_domains_and_infos conn flags =
460 (* Old/slow/inefficient method. *)
461 let get_active, get_inactive =
462 if List.mem ListAll flags then
464 else (List.mem ListActive flags, List.mem ListInactive flags) in
467 let n = Connect.num_of_domains conn in
468 let ids = Connect.list_domains conn n in
469 let ids = Array.to_list ids in
470 map_ignore_errors (lookup_by_id conn) ids
474 if get_inactive then (
475 let n = Connect.num_of_defined_domains conn in
476 let names = Connect.list_defined_domains conn n in
477 let names = Array.to_list names in
478 map_ignore_errors (lookup_by_name conn) names
481 let doms = active_doms @ inactive_doms in
483 map_ignore_errors (fun dom -> (dom, get_info dom)) doms
490 external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_network_lookup_by_name"
491 external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_network_lookup_by_uuid"
492 external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_network_lookup_by_uuid_string"
493 external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_network_create_xml"
494 external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_network_define_xml"
495 external undefine : [>`W] t -> unit = "ocaml_libvirt_network_undefine"
496 external create : [>`W] t -> unit = "ocaml_libvirt_network_create"
497 external destroy : [>`W] t -> unit = "ocaml_libvirt_network_destroy"
498 external free : [>`R] t -> unit = "ocaml_libvirt_network_free"
499 external get_name : [>`R] t -> string = "ocaml_libvirt_network_get_name"
500 external get_uuid : [>`R] t -> uuid = "ocaml_libvirt_network_get_uuid"
501 external get_uuid_string : [>`R] t -> string = "ocaml_libvirt_network_get_uuid_string"
502 external get_xml_desc : [>`R] t -> xml = "ocaml_libvirt_network_get_xml_desc"
503 external get_bridge_name : [>`R] t -> string = "ocaml_libvirt_network_get_bridge_name"
504 external get_autostart : [>`R] t -> bool = "ocaml_libvirt_network_get_autostart"
505 external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_network_set_autostart"
507 external const : [>`R] t -> ro t = "%identity"
513 type pool_state = Inactive | Building | Running | Degraded
514 type pool_build_flags = New | Repair | Resize
515 type pool_delete_flags = Normal | Zeroed
523 external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_name"
524 external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid"
525 external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid_string"
526 external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_create_xml"
527 external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_define_xml"
528 external build : [>`W] t -> pool_build_flags -> unit = "ocaml_libvirt_storage_pool_build"
529 external undefine : [>`W] t -> unit = "ocaml_libvirt_storage_pool_undefine"
530 external create : [>`W] t -> unit = "ocaml_libvirt_storage_pool_create"
531 external destroy : [>`W] t -> unit = "ocaml_libvirt_storage_pool_destroy"
532 external delete : [>`W] t -> unit = "ocaml_libvirt_storage_pool_delete"
533 external free : [>`R] t -> unit = "ocaml_libvirt_storage_pool_free"
534 external refresh : [`R] t -> unit = "ocaml_libvirt_storage_pool_refresh"
535 external get_name : [`R] t -> string = "ocaml_libvirt_storage_pool_get_name"
536 external get_uuid : [`R] t -> uuid = "ocaml_libvirt_storage_pool_get_uuid"
537 external get_uuid_string : [`R] t -> string = "ocaml_libvirt_storage_pool_get_uuid_string"
538 external get_info : [`R] t -> pool_info = "ocaml_libvirt_storage_pool_get_info"
539 external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_pool_get_xml_desc"
540 external get_autostart : [`R] t -> bool = "ocaml_libvirt_storage_pool_get_autostart"
541 external set_autostart : [>`W] t -> bool -> unit = "ocaml_libvirt_storage_pool_set_autostart"
542 external num_of_volumes : [`R] t -> int = "ocaml_libvirt_storage_pool_num_of_volumes"
543 external list_volumes : [`R] t -> int -> string array = "ocaml_libvirt_storage_pool_list_volumes"
544 external const : [>`R] t -> ro t = "%identity"
550 type vol_type = File | Block
551 type vol_delete_flags = Normal | Zeroed
558 external lookup_by_name : 'a Pool.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_name"
559 external lookup_by_key : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_key"
560 external lookup_by_path : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_path"
561 external pool_of_volume : 'a t -> 'a Pool.t = "ocaml_libvirt_storage_pool_lookup_by_volume"
562 external get_name : [`R] t -> string = "ocaml_libvirt_storage_vol_get_name"
563 external get_key : [`R] t -> string = "ocaml_libvirt_storage_vol_get_key"
564 external get_path : [`R] t -> string = "ocaml_libvirt_storage_vol_get_path"
565 external get_info : [`R] t -> vol_info = "ocaml_libvirt_storage_vol_get_info"
566 external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_vol_get_xml_desc"
567 external create_xml : [>`W] Pool.t -> xml -> unit = "ocaml_libvirt_storage_vol_create_xml"
568 external delete : [>`W] t -> vol_delete_flags -> unit = "ocaml_libvirt_storage_vol_delete"
569 external free : [>`R] t -> unit = "ocaml_libvirt_storage_vol_free"
570 external const : [>`R] t -> ro t = "%identity"
573 (* Initialization. *)
574 external c_init : unit -> unit = "ocaml_libvirt_init"
576 Callback.register_exception
577 "ocaml_libvirt_virterror" (Virterror (Virterror.no_error ()));
578 Callback.register_exception
579 "ocaml_libvirt_not_supported" (Not_supported "");