This one is a 'one-off' but it ought to be possible to use the generator
to create the function (it has signature 'conn, int, int : int')
This function first appeared in libvirt version 0.9.8.
Signed-off-by: David Scott <dave.scott(a)eu.citrix.com>
---
libvirt/libvirt.ml | 2 ++
libvirt/libvirt.mli | 8 ++++++++
libvirt/libvirt_c_oneoffs.c | 17 +++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml
index 1fbb8ca..784a2b5 100644
--- a/libvirt/libvirt.ml
+++ b/libvirt/libvirt.ml
@@ -100,6 +100,8 @@ struct
let cpu_usable cpumaps maplen vcpu cpu =
Char.code cpumaps.[vcpu*maplen + cpu/8] land (1 lsl (cpu mod 8)) <> 0
+ external set_keep_alive : [>`R] t -> int -> int -> unit =
"ocaml_libvirt_connect_set_keep_alive"
+
external const : [>`R] t -> ro t = "%identity"
end
diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli
index 0185402..fa5a0fe 100644
--- a/libvirt/libvirt.mli
+++ b/libvirt/libvirt.mli
@@ -384,6 +384,14 @@ sig
(** [cpu_usable cpumaps maplen vcpu cpu] checks returns true iff the
[cpu] is usable by [vcpu]. *)
+ val set_keep_alive : [>`R] t -> int -> int -> unit
+ (** [set_keep_alive conn interval count] starts sending keepalive
+ messages after [interval] seconds of inactivity and consider the
+ connection to be broken when no response is received after [count]
+ keepalive messages.
+ Note: the client has to implement and run an event loop to
+ be able to use keep-alive messages. *)
+
external const : [>`R] t -> ro t = "%identity"
(** [const conn] turns a read/write connection into a read-only
connection. Note that the opposite operation is impossible.
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index 42301b7..c51aad7 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -169,6 +169,23 @@ ocaml_libvirt_connect_node_get_cells_free_memory (value connv,
}
CAMLprim value
+ocaml_libvirt_connect_set_keep_alive(value connv,
+ value intervalv, value countv)
+{
+ CAMLparam3 (connv, intervalv, countv);
+ virConnectPtr conn = Connect_val(connv);
+ int interval = Int_val(intervalv);
+ unsigned int count = Int_val(countv);
+ int r;
+
+ NONBLOCKING(r = virConnectSetKeepAlive(conn, interval, count));
+ CHECK_ERROR (r == -1, conn, "virConnectSetKeepAlive");
+
+ CAMLreturn(Val_unit);
+}
+
+
+CAMLprim value
ocaml_libvirt_domain_get_id (value domv)
{
CAMLparam1 (domv);
--
1.8.1.2