Displaying 20 results from an estimated 32 matches for "caml_format_except".
2020 Sep 01
0
[nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...struct nbdkit_exports *exports)
+{
+ CAMLparam0 ();
+ CAMLlocal2 (rv, v);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback2_exn (list_exports_fn, Val_bool (readonly),
+ Val_bool (is_tls));
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ /* Convert exports list into calls to nbdkit_add_export. */
+ while (rv != Val_int (0)) {
+ const char *name, *desc;
+
+ v = Field (rv, 0); /* export struct */
+ name = String...
2020 Sep 21
0
[nbdkit PATCH v3 14/14] ocaml: Implement .list_exports and friends
...struct nbdkit_exports *exports)
+{
+ CAMLparam0 ();
+ CAMLlocal2 (rv, v);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback2_exn (list_exports_fn, Val_bool (readonly),
+ Val_bool (is_tls));
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ /* Convert exports list into calls to nbdkit_add_export. */
+ while (rv != Val_emptylist) {
+ const char *name, *desc = NULL;
+
+ v = Field (rv, 0); /* export struct */
+ name...
2019 May 17
1
Re: [nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
...t; +static int
> +can_cache_wrapper (void *h)
> +{
> + CAMLparam0 ();
> + CAMLlocal1 (rv);
> +
> + caml_leave_blocking_section ();
> +
> + rv = caml_callback_exn (can_cache_fn, *(value *) h);
> + if (Is_exception_result (rv)) {
> + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
> + caml_enter_blocking_section ();
> + CAMLreturnT (int, -1);
> + }
> +
> + caml_enter_blocking_section ();
> + CAMLreturnT (int, Int_val (rv));
The not very obvious implicit assumption here is that the order of the
Cache* flags in the OCam...
2019 May 16
0
[nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
...offset, uint32_t flags,
CAMLreturnT (int, 0);
}
+static int
+can_cache_wrapper (void *h)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback_exn (can_cache_fn, *(value *) h);
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, Int_val (rv));
+}
+
+static int
+cache_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t flags)
+{
+ CAMLparam0 ();
+ CAMLlocal4...
2017 Jan 27
2
Re: [nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
...d *h, void *buf, uint32_t count, uint64_t offset)
{
CAMLparam0 ();
CAMLlocal3 (rv, strv, offsetv);
+ int saved_errno;
...
rv = caml_callback3_exn (pread_fn, *(value *) h, strv, offsetv);
+ saved_errno = errno;
if (Is_exception_result (rv)) {
nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
caml_enter_blocking_section ();
+ errno = saved_errno;
CAMLreturnT (int, -1);
}
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v...
2020 Feb 10
1
[nbdkit PATCH] ocaml: Support .preconnect callback
...CAMLreturnT (int, Bool_val (rv));
}
+static int
+preconnect_wrapper (int readonly)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback_exn (preconnect_fn, Val_bool (readonly));
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, 1);
+}
+
/*----------------------------------------------------------------------*/
/* set_* functions called from OCaml code at load time...
2017 Jan 27
0
Re: [nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
...set)
> {
> CAMLparam0 ();
> CAMLlocal3 (rv, strv, offsetv);
> + int saved_errno;
> ...
> rv = caml_callback3_exn (pread_fn, *(value *) h, strv, offsetv);
> + saved_errno = errno;
> if (Is_exception_result (rv)) {
> nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
> caml_enter_blocking_section ();
> + errno = saved_errno;
> CAMLreturnT (int, -1);
Okay, I'll respin the patch along these lines.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
2020 Sep 01
4
[nbdkit PATCH 0/2] More language bindings for .list_exports
This picks up python and ocaml. Some of our languages are lacking a
number of bindings (for example, lua and perl lack .extents, so I
didn't have anything to copy from), and I felt less comfortable with
golang and rust. But for python and ocaml, I was able to test a
working implementation.
Eric Blake (2):
python: Implement .list_exports and friends
ocaml: Implement .list_exports and
2019 Apr 23
0
[PATCH nbdkit v2 1/2] ocaml: Change pread method to avoid leaking heap memory.
...;
flagsv = Val_flags (flags);
- value args[] = { *(value *) h, strv, offsetv, flagsv };
+ value args[] = { *(value *) h, countv, offsetv, flagsv };
rv = caml_callbackN_exn (pread_fn, sizeof args / sizeof args[0], args);
if (Is_exception_result (rv)) {
nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
@@ -455,7 +456,14 @@ pread_wrapper (void *h, void *buf, uint32_t count, uint64_t offset,
CAMLreturnT (int, -1);
}
- memcpy (buf, String_val (strv), count);
+ len = caml_string_length (rv);
+ if (len < count) {
+ nbdkit_error ("buffer returned fr...
2019 Aug 15
2
[nbdkit PATCH] ocaml: Add support for dynamic .thread_model
...fset, uint32_t flags)
CAMLreturnT (int, 0);
}
+static int
+thread_model_wrapper (void)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback_exn (config_complete_fn, Val_unit);
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, Int_val (rv));
+}
+
/*----------------------------------------------------------------------*/
/* set_* functions called from OCaml code at...
2019 Jun 04
0
[PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...what exception.\n";
+ pr " * means error versus unexpected failure.\n";
+ pr " */\n";
pr " fprintf (stderr,\n";
pr " \"libnbd: uncaught OCaml exception: %%s\",\n";
pr " caml_format_exception (Extract_exception (rv)));\n";
+ pr " CAMLreturnT (int, -1);\n";
+ pr " }\n";
pr "\n";
- pr " CAMLreturn0;\n";
+ pr " CAMLreturnT (int, 0);\n";
pr "}\n";
pr "\n";
-...
2019 Apr 23
4
[PATCH nbdkit v2 0/2] Be careful not to leak server heap memory to the client.
Version 1 was here:
https://www.redhat.com/archives/libguestfs/2019-April/msg00144.html
Version 2 makes a couple of much larger changes:
The OCaml patch changes the API of the pread method so it matches what
other language bindings are already doing, ie. get the language plugin
to return a newly allocated buffer, check it is long enough, copy out
the data.
The server patch implements a
2019 Jun 25
3
[PATCH libnbd] generator: Add Mutable type to the generator.
...llback _ | CallbackPersist _
+ | Flags _ | Int _ | Int64 _ | Mutable _
+ | Path _ | SockAddrAndLen _ | StringList _
| UInt _ | UInt32 _ -> assert false
) args;
@@ -4047,6 +4087,15 @@ let print_ocaml_binding (name, { args; ret }) =
pr " caml_format_exception (Extract_exception (rv)));\n";
pr " CAMLreturnT (int, -1);\n";
pr " }\n";
+
+ List.iter (
+ function
+ (* Mutable must be copied back to the C pointer. *)
+ | Mutable (Int n) ->
+ pr " *%s = Int_val (F...
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...;
- pr " * means error versus unexpected failure.\n";
- pr " */\n";
- pr " fprintf (stderr,\n";
- pr " \"libnbd: uncaught OCaml exception: %%s\\n\",\n";
- pr " caml_format_exception (Extract_exception (rv)));\n";
- pr " CAMLreturnT (int, -1);\n";
- pr " }\n";
+ pr " if (Is_exception_result (rv)) {\n";
+ pr " /* XXX This is not really an error as callbacks can return\n";
+ pr "...
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them. Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure. Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't
2019 Aug 23
2
[nbdkit PATCH 3/3] plugins: Add .can_fast_zero hook
...oid)
CAMLreturnT (int, Int_val (rv));
}
+static int
+can_fast_zero_wrapper (void *h)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback_exn (can_fast_zero_fn, *(value *) h);
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, Bool_val (rv));
+}
+
/*----------------------------------------------------------------------*/
/* set_* functions called from OCaml code a...
2020 Feb 25
6
[PATCH nbdkit 0/5] server: Add .get_ready callback.
I like this change. I think we were overloading the config_complete
method before to do two different things (complete configuration; do
any allocation/housekeeping necessary before we can start serving).
The only questions in my mind are whether we want this before 1.18,
and whether the name ("get_ready") is a good one.
Rich.
2019 Jan 04
10
[PATCH nbdkit 0/7] server: Implement NBD_FLAG_CAN_MULTI_CONN.
First thing to say is that I need to do a *lot* more testing on this,
so this is just an early peek. In particular, although it passed
‘make check && make check-valgrind’ I have *not* tested it against a
multi-conn-aware client such as the Linux kernel >= 4.9.
This implements NBD_FLAG_CAN_MULTI_CONN, described in the protocol doc
as:
"NBD_FLAG_CAN_MULTI_CONN: Indicates that
2019 Jan 05
15
[PATCH nbdkit v2 01/11] server: Implement NBD_FLAG_CAN_MULTI_CONN.
For existing commits, this is almost identical to v1, except that I
updated some commit messages and reordered the commits in a somewhat
more logical sequence.
The main changes are the extra commits:
[06/11] plugins: Return NBD_FLAG_CAN_MULTI_CONN from some readonly plugins.
- Readonly plugins that can set the flag unconditionally.
[09/11] partitioning: Return NBD_FLAG_CAN_MULTI_CONN.
[10/11]
2020 Jun 22
4
[PATCH nbdkit 1/2] server: Add .after_fork callback, mainly for plugins to create threads.
...@@ get_ready_wrapper (void)
CAMLreturnT (int, 0);
}
+static int
+after_fork_wrapper (void)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ caml_leave_blocking_section ();
+
+ rv = caml_callback_exn (after_fork_fn, Val_unit);
+ if (Is_exception_result (rv)) {
+ nbdkit_error ("%s", caml_format_exception (Extract_exception (rv)));
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, -1);
+ }
+
+ caml_enter_blocking_section ();
+ CAMLreturnT (int, 0);
+}
+
static int
preconnect_wrapper (int readonly)
{
@@ -833,6 +853,7 @@ SET(config_complete)
SET(thread_model)
SET(get_ready)
+SET...