Add event callback implementation based on virConnectDomainEventRegisterAny
A client may register a callback as follows:
E.register_default_impl ();
let conn = C.connect_readonly ?name () in
let id = E.register_any conn (E.Lifecycle (fun dom e ->
printd dom "Lifecycle %s" (E.Lifecycle.to_string e)
)) in
Internally this will:
1. generate a unique int64 used to identify the specific callback
2. add the callback to an OCaml hashtable based on the signature
(there is a distinct hashtable per callback signature)
3. call virConnectDomainEventRegisterAny which registers a
generic C callback in the stubs (one distinct callback per
signature) and supply the int64 as the "opaque" data
The client must enter the event loop with:
while true do
E.run_default_impl ()
done
When an event is triggered, the C callback will upcall into an OCaml
function (having re-acquired the heap lock) supplying the int64 value.
The OCaml function can then find the right callback in the Hashtbl
and call it.
The client can deregister the callback with:
E.deregister_any conn id;
Signed-off-by: David Scott <dave.scott@eu.citrix.com>