[Libguestfs] [nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
Richard W.M. Jones
rjones at redhat.com
Fri May 17 17:16:03 UTC 2019
On Wed, May 15, 2019 at 10:57:58PM -0500, Eric Blake wrote:
> +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 OCaml code is the same as the numbering of the
NBDKIT_CACHE_* flags in the C code, which it is, so we should be good.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list