nbdkit Lua binding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

nbdkit Lua binding

Richard W.M. Jones
nbdkit is a pluggable Network Block Device (NBD) server.  We allow
people to write plugins using various scripting languages.

I wrote Lua bindings for nbdkit yesterday:


I've only tested them lightly, and there are bound to be some bugs.

If anyone has any comments about the code style / naturalness of the
Lua bindings / horrible bugs then I'd be pleased to get feedback
(please CC me).

Some issues I had:

 - Is there a mutable string / buffer type in the standard library?
   (see https://github.com/libguestfs/nbdkit/blob/dfa6f5b580b6436d0742cc2e072bce0fbdc43b77/tests/test.lua#L22 )

 - Error messages generated by Lua are very nice and easy to read.

 - Is lua_Integer guaranteed to be >= 64 bit even on 32 bit platforms?
   (see awkward code here: https://github.com/libguestfs/nbdkit/blob/dfa6f5b580b6436d0742cc2e072bce0fbdc43b77/plugins/lua/lua.c#L227 )

 - io.open (...,"rb+") does not work, but "r+b" works.  Even worse
   "rb+" doesn't seem to give an error, it just fails when I try to
   write to the handle.  That was the thing which took me longest to

 - strings in Lua code indexed from 1 ... zaaarghhh :-(

I've implemented nbdkit bindings for 6 non-C languages and Lua has
certainly been one of the nicer ones to deal with, once you get used
to how the stack works.


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org