[To continue the conversation from https://github.com/libguestfs/nbdkit/issues/5]
> Currently there's no way for the Rust plugin to report an error. The > idiomatic way to do it would be for each callback to return a Result > object, much like how the Go plugin currently does it. I'm sure it's not idiomatic for Rust, but I just wanted to say that there is a way to return an error: return -1. But a bigger issue seems to be how to pass back the correct errno (assuming that Rust even collects this from low-level syscalls?). For historical reasons nbdkit plugins written in C set errno on error and nbdkit server reads the errno and may translate it into NBD errors on the wire (so it's generally important to get it right). However your plugin may set .errno_is_preserved = 0, then you can call nbdkit_set_error() whenever convenient before returning an error to set the errno that nbdkit will use. In OCaml plugins we have to go through some hoops to convert OCaml errno (which use a different numbering) to system errno: https://github.com/libguestfs/nbdkit/blob/904c4e5fdca557d6d25a60e6fb12fa058263481e/plugins/ocaml/NBDKit.ml#L250 The other issue (from golang bindings) was threads. Does Rust use native system pthreads? If it does then there shouldn't be an issue. golang implements its own green threads and that was a problem. Rich. -- 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 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
