[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/8] tools/ocaml/evtchn: Add binding for xenevtchn_fdopen()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 22 Nov 2022 15:20:38 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edvin.torok@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Delivery-date: Tue, 22 Nov 2022 15:21:14 +0000
  • Ironport-data: A9a23:/m1Og6wtyNzAYIc9EMN6t+dlxirEfRIJ4+MujC+fZmUNrF6WrkUGz mceWGzSPa7YNjT8fIglYIWwoB4CsJPSzdJiGQU4rCAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTbaeYUidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+U0HUMja4mtC5AVnP6oT4DcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KTwfy u4ZLj0KUh6KoOeM0erqbOdQmNt2eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKQOHWjOX9OYH46tM6uimPybHtzr1WNqLBsy2PS0BZwwP7mN9+9ltmiFZkExB7E+ DuuE2LRMhcdNPmv5Rm81U2229HxrAarBLovLejtnhJtqALKnTFCYPEMbnO3qOe0olSzUNVeL woT4CVGhbg/8gmnQ8fwWzW8oWWYpVgMVtxICeo45QqRjK3O7G6k6nMsF2AbLoZ87YlvGGJsh gThc87V6SJH7eyqW3Ob+7CoozqVPBIEdT4kaxMaUl5QizX8m73fni4jX/46TvDk1o2uQGChq 9yZhHNg3utO1Kbnw43+pAma2Gz0+/AlWyZvvm3qsnSZAhSVjWJPT6ih8hDl4PlJN+51pXHR7 SFfy6ByAA3jZKxhdRBho81XRtlFH97fbFXhbadHRvHMN12FohZPh7x47jBkP1tOOc0ZYzLva 0K7kVoPus4LYSb0MvUpPd3Z5yEWIU/ITISNaxwpRoAWPsgZmPGvoUmCmnJ8L0iyyRNxwMnTy L+QcNq2DGZyNEiU5GPeegrcuJd1rh0DKZT7H82nn0/+iODGDJNXIJ9cWGazgikCxPvsiG3oH xx3baNmFz03vDXCXxTq
  • Ironport-hdrordr: A9a23:wxi1dKDj1Ql8FhDlHemq55DYdb4zR+YMi2TC1yhKJiC9Ffbo8f xG/c5rsiMc5wxxZJhNo7290ey7MBHhHP1OkO0s1NWZPDUO0VHAROoJ0WKh+UyEJ8SXzJ8l6U 4KScZD4bPLYWSS9fyKgzWFLw==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Edwin Török <edvin.torok@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
---
CC: Christian Lindig <christian.lindig@xxxxxxxxxx>
CC: David Scott <dave@xxxxxxxxxx>
CC: Edwin Torok <edvin.torok@xxxxxxxxxx>
CC: Rob Hoes <Rob.Hoes@xxxxxxxxxx>

Split out of combined patch
---
 tools/ocaml/libs/eventchn/xeneventchn.ml      |  1 +
 tools/ocaml/libs/eventchn/xeneventchn.mli     |  4 ++++
 tools/ocaml/libs/eventchn/xeneventchn_stubs.c | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/tools/ocaml/libs/eventchn/xeneventchn.ml 
b/tools/ocaml/libs/eventchn/xeneventchn.ml
index dd00a1f0ead5..be4de82f46b9 100644
--- a/tools/ocaml/libs/eventchn/xeneventchn.ml
+++ b/tools/ocaml/libs/eventchn/xeneventchn.ml
@@ -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
diff --git a/tools/ocaml/libs/eventchn/xeneventchn.mli 
b/tools/ocaml/libs/eventchn/xeneventchn.mli
index 08c73376438e..98b3c86f3702 100644
--- a/tools/ocaml/libs/eventchn/xeneventchn.mli
+++ b/tools/ocaml/libs/eventchn/xeneventchn.mli
@@ -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'.
diff --git a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c 
b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
index 37f1cc4e1478..7bdf711bc150 100644
--- a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
+++ b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
@@ -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);
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.