On 07/01/2018 09:59 AM, Richard W.M. Jones wrote:
This lets you write simple plugins in Tcl. All the basic features of nbdkit are supported, but serious Tcl users will probably want to enhance the plugin further.
Unfortunately Tcl as a language is not very well suited to handling binary data. It prefers to store binary data in UCS-2 strings, meaning that every second byte is wasted. Also there appears to be no way to replace part of such a string/array in-place.
Strictly speaking Tcl requires that:
"only the thread that created a Tcl interpreter can use that interpreter. In other words, multiple threads can not access the same Tcl interpreter."
Apparently this applies even if nbdkit uses mutexes to ensure that multiple threads are not calling into the interpreter at the same time. We do not have such a threading model in nbdkit (see also VDDK) but at the same time I was not able to get Tcl to crash.
The Tcl interpreter leaks quite a lot of memory from the tcl_load and tcl_open calls. This may be connected with the previous point. It makes valgrind fairly useless so it is disabled for Tcl. ---
+=item C<is_rotational> + +(Optional) + + proc is_rotational {h} { + return $bool + } + +Return a boolean indicating whether the disk is rotational. + +=item C<can_trim> + +(Optional) + + proc can_trim {h} { + return $bool + } + +Return a boolean indicating whether trim/discard can be performed. +
Should we also expose can_fua, can_zero?
+=head2 MISSING CALLBACKS + +=over 4 + +=item Missing: C<load>, C<unload>, C<name>, C<version>, C<longname>, C<description>, C<config_help> + +These are not yet supported.
If you don't want to support can_zero/can_fua yet, should you document them here?
+++ b/plugins/tcl/tcl.c
+static Tcl_Interp *interp; +static const char *script; + +static void +tcl_load (void) +{ + //Tcl_FindExecutable ("nbdkit");
Is this comment intentional? Otherwise LGTM -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org