]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
tools/ocaml/evtchn: Add binding for xenevtchn_fdopen()
authorEdwin Török <edvin.torok@citrix.com>
Mon, 14 Nov 2022 13:36:19 +0000 (13:36 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Dec 2022 16:07:17 +0000 (16:07 +0000)
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>
tools/ocaml/libs/eventchn/xeneventchn.ml
tools/ocaml/libs/eventchn/xeneventchn.mli
tools/ocaml/libs/eventchn/xeneventchn_stubs.c

index dd00a1f0ead558209568df4d1205782359e41276..be4de82f46b992e55f362d7572ff6e6595c2487f 100644 (file)
@@ -17,6 +17,7 @@
 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
index 08c73376438e37d3a993a460b8349fa2e8def4e6..98b3c86f3702684f4a25153d76d91b9d13aa10ea 100644 (file)
@@ -47,6 +47,10 @@ val init: unit -> handle
 (** 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'.
index 37f1cc4e1478064bf5c2a66cc9367a09d4f76084..7bdf711bc150694ba4c405e70ec9c7db96f06d7b 100644 (file)
@@ -69,6 +69,25 @@ CAMLprim value stub_eventchn_init(void)
        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);