For live update, the new oxenstored needs to reconstruct an evtchn object
around an existing file descriptor.
Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
type handle
external init: unit -> handle = "stub_eventchn_init"
+external fdopen: Unix.file_descr -> handle = "stub_eventchn_fdopen"
external fd: handle -> Unix.file_descr = "stub_eventchn_fd"
type t = int
(** Return an initialised event channel interface. On error it
will throw a Failure exception. *)
+val fdopen: Unix.file_descr -> handle
+(** Return an initialised event channel interface, from an already open evtchn
+ file descriptor. On error it will throw a Failure exception. *)
+
val fd: handle -> Unix.file_descr
(** Return a file descriptor suitable for Unix.select. When
the descriptor becomes readable, it is safe to call 'pending'.
CAMLreturn(result);
}
+CAMLprim value stub_eventchn_fdopen(value fdval)
+{
+ CAMLparam1(fdval);
+ CAMLlocal1(result);
+ xenevtchn_handle *xce;
+
+ caml_enter_blocking_section();
+ xce = xenevtchn_fdopen(NULL, Int_val(fdval), 0);
+ caml_leave_blocking_section();
+
+ if (xce == NULL)
+ caml_failwith("evtchn fdopen failed");
+
+ result = caml_alloc_custom(&xenevtchn_ops, sizeof(xce), 0, 1);
+ _H(result) = xce;
+
+ CAMLreturn(result);
+}
+
CAMLprim value stub_eventchn_fd(value xce)
{
CAMLparam1(xce);