Re: [Libguestfs] [nbdkit PATCH 2/5] protocol: Validate request flags

2017-01-25 Thread Eric Blake
On 01/20/2017 02:16 PM, Eric Blake wrote: > Reject rather than silently ignoring unknown client request flags. > > > + /* Validate flags */ > + if (flags & ~NBD_CMD_FLAG_FUA) { > +nbdkit_error ("invalid request: unknown flag (0x%x)", flags); > +*error = EINVAL; > +return 0; > + }

Re: [Libguestfs] [nbdkit PATCH 0/2] bind .zero to more languages

2017-01-25 Thread Eric Blake
On 01/24/2017 09:16 AM, Richard W.M. Jones wrote: > In Perl, old code to raise an error would look like: > > sub pread > { > my $h = shift; > my $count = shift; > my $offset = shift; > my $ret; > read ($FH, $ret, $count, $offset) || die "read: $!" > return $ret;

[Libguestfs] [nbdkit PATCH v2 5/6] python: Expose nbdkit_set_error to python script

2017-01-25 Thread Eric Blake
In addition to calling python functions from C, we want to make script writing easier by exposing C functions to python. For now, just wrap nbdkit_set_error(), as that will be needed for an optimal implementation of a zero() callback. Signed-off-by: Eric Blake ---

[Libguestfs] [nbdkit PATCH v2 2/6] protocol: Map EROFS to EPERM

2017-01-25 Thread Eric Blake
The NBD Protocol requests an EPERM failure on attempts to write to a read-only export. We were internally using EROFS, but our mapping was slamming that to EINVAL. Signed-off-by: Eric Blake --- src/connections.c | 1 + 1 file changed, 1 insertion(+) diff --git

[Libguestfs] [nbdkit PATCH v2 6/6] python: Support zero callback

2017-01-25 Thread Eric Blake
Add a python language binding for the .zero callback, used for implementing NBD_CMD_WRITE_ZEROES. The caller doesn't have to return anything, but should use nbdkit.set_error(errno.EOPNOTSUPP) to get an automatic fallback to pwrite. Enhance the example to show the use of the fallback mechanism,

[Libguestfs] [nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function

2017-01-25 Thread Eric Blake
The plugin interface was impliticly using the last errno value as the source for any error code sent over the wire to the client. This is okay for C, but in other language bindings, it gets rather awkward when you can't guarantee what errno will even be set to by the time the binding glue has

[Libguestfs] [nbdkit PATCH v2 0/6] bind .zero to Python

2017-01-25 Thread Eric Blake
Fix some things I noticed while reviewing v1, and follow Rich's idea to add a new nbdkit_set_error() utility function with a binding for Python users to request a particular error (rather than being forced to live with whatever stale value is in errno after all the intermediate binding glue code).

[Libguestfs] [PATCH v2 1/7] lib: Share common protocol and errnostring libraries with the library and daemon.

2017-01-25 Thread Richard W.M. Jones
This commit, which is just code motion, moves the common XDR protocol code (libprotocol) and the common errno handling (liberrnostring) into libraries which are each built once and shared between the library and daemon. --- .gitignore | 20 + Makefile.am

[Libguestfs] [PATCH v2 3/7] Rename src/ to lib/

2017-01-25 Thread Richard W.M. Jones
--- .gitignore | 40 - Makefile.am | 2 +- align/Makefile.am| 4 +- builder/Makefile.am | 8 +- cat/Makefile.am | 20 ++--- cfg.mk

[Libguestfs] [PATCH v2 4/7] cat: Move visit library to new directory common/visit.

2017-01-25 Thread Richard W.M. Jones
Just code motion. --- Makefile.am | 3 +++ cat/Makefile.am | 6 +++--- common/visit/Makefile.am | 33 + {cat => common/visit}/visit.c | 0 {cat => common/visit}/visit.h | 0 configure.ac | 1 +

[Libguestfs] [PATCH v2 5/7] fish: Move fishcommon library to common/options.

2017-01-25 Thread Richard W.M. Jones
This is mostly code motion but: (1) I had to remove the compile-time COMPILING_GUESTFISH and COMPILING_VIRT_RESCUE macros and replace them with runtime constants and checks. (2) I moved the fish/config.c file into this library. --- Makefile.am| 2 +-

[Libguestfs] [PATCH v2 7/7] df: Move framework for processing domains in parallel to common/parallel.

2017-01-25 Thread Richard W.M. Jones
Just code motion. --- Makefile.am| 1 + align/Makefile.am | 13 +-- common/parallel/Makefile.am| 51 ++ {df => common/parallel}/domains.c | 0 {df =>

[Libguestfs] [PATCH v2 0/7] Rename src/ to lib/ and move common code to common/

2017-01-25 Thread Richard W.M. Jones
Previous patch series was posted here: https://www.redhat.com/archives/libguestfs/2017-January/msg00059.html v2 simply extends this patch series to cover the extra directories common/edit, common/progress, common/windows and common/parallel. The only remaining item is to consider whether we