[Libguestfs] [nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins

2017-01-26 Thread Eric Blake
It is very unlikely that the value of errno after completing the glue code in between the completion of the user's callback and the point in time where we construct the client's reply is going to be untouched, which means that we are likely to send the wrong error code across the wire. Add a new

[Libguestfs] [nbdkit PATCH v3 0/4] bind .zero to Python

2017-01-26 Thread Eric Blake
This cleans up the existing code base with regards to implicit use of errno from language bindings, then rebases the previous work in python on top of that. I'm still playing with the perl bindings, but got further after reading 'perldoc perlembed'. Eric Blake (4): plugins: Don't use bogus

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

2017-01-26 Thread Eric Blake
The last patch fixed the plugin interface to not use a bogus value of errno from other language bindings, but hard-coding things to EIO is not nice either. The solution is to expose an explicit utility function for setting the preferred error value, while still falling back to errno for backwards

[Libguestfs] [nbdkit PATCH v3 3/4] python: Expose nbdkit_set_error to python script

2017-01-26 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 --- v2: tweak

[Libguestfs] [nbdkit PATCH v3 4/4] python: Support zero callback

2017-01-26 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] [PATCH v2 1/2] common/edit: Don't use random() function.

2017-01-26 Thread Richard W.M. Jones
Generate the random filename using our utility function guestfs_int_random_string. This also means that we will not need to call srandom() in guestfish or virt-edit. --- common/edit/file-edit.c | 18 ++ edit/edit.c | 3 --- fish/fish.c | 3 --- 3 files

[Libguestfs] [PATCH v2 2/2] tests/mount-local, tests/parallel: Use srandom (time (NULL) + getpid ()).

2017-01-26 Thread Richard W.M. Jones
If two instances of the test start at exactly the same time, they would have the same random number seed. --- tests/mount-local/test-parallel-mount-local.c | 2 +- tests/parallel/test-parallel.c| 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git

[Libguestfs] [PATCH v2 0/2] Fix srandom issues.

2017-01-26 Thread Richard W.M. Jones
A better way to solve this I think. Rich. ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs

Re: [Libguestfs] [PATCH] Use srandom (time (NULL) + getpid ()) throughout.

2017-01-26 Thread Richard W.M. Jones
On Thu, Jan 26, 2017 at 03:51:20PM +, Richard W.M. Jones wrote: > It avoids two programs which start at exactly the same time from > having the same random number seed, which helps in some tests. Ignore this patch, better one to come. Rich. -- Richard Jones, Virtualization Group, Red Hat

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

2017-01-26 Thread Richard W.M. Jones
On Thu, Jan 26, 2017 at 04:57:32PM +0100, Pino Toscano wrote: > On Wednesday, 25 January 2017 14:37:10 CET Richard W.M. Jones wrote: > > This commit, which is just code motion, moves the common XDR protocol > > code (libprotocol) and the common errno handling (liberrnostring) into > > libraries

Re: [Libguestfs] [PATCH v2 2/7] lib: Move utilities to new directory common/utils.

2017-01-26 Thread Pino Toscano
On Wednesday, 25 January 2017 14:37:11 CET Richard W.M. Jones wrote: > Just code motion. > > This commit makes it clearer what is a utility and what is part of the > library. It also makes it clear that we should rename: > > guestfs-internal-frontend.h -> utils.h >

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

2017-01-26 Thread Pino Toscano
On Wednesday, 25 January 2017 14:37:09 CET Richard W.M. Jones wrote: > 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,

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

2017-01-26 Thread Richard W.M. Jones
On Thu, Jan 26, 2017 at 08:21:17AM -0600, Eric Blake wrote: > On 01/26/2017 04:13 AM, Richard W.M. Jones wrote: > > On Wed, Jan 25, 2017 at 08:42:34PM -0600, Eric Blake wrote: > >> +eg. NULL or -1. If the call to C is omitted, then > >> +the value of C will be used instead. > > [...] > >> +/*

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

2017-01-26 Thread Pino Toscano
On Wednesday, 25 January 2017 14:37:10 CET Richard W.M. Jones wrote: > 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. >

[Libguestfs] [PATCH 1/3] p2v: In non-ISO environment, don't use hard-coded port 50123.

2017-01-26 Thread Richard W.M. Jones
When testing virt-p2v (eg. on the host machine) this prevents us from testing two instances of virt-p2v at the same time because both will try to use the same port. --- p2v/main.c | 16 p2v/p2v.h | 5 + p2v/ssh.c | 3 --- 3 files changed, 21 insertions(+), 3 deletions(-)

[Libguestfs] [PATCH 0/3] p2v: Allow nbdkit as an alternative NBD server.

2017-01-26 Thread Richard W.M. Jones
qemu-nbd is a fine NBD server. However it's not easy to compile a reliably working version on RHEL 5. This patch series allows nbdkit to be used as an alternative (qemu-nbd is still the default). Rich. ___ Libguestfs mailing list

[Libguestfs] [PATCH 2/3] p2v: Allow nbdkit as an alternative NBD server to qemu-nbd.

2017-01-26 Thread Richard W.M. Jones
Add code in virt-p2v so that it can use nbdkit (with the file plugin) as an alternative to qemu-nbd. This is controlled through the virt-p2v --nbd command line option, allowing you to select which server (out of qemu-nbd or nbdkit) you prefer (with a fallback). The default is:

[Libguestfs] [PATCH 3/3] p2v: Add a test for virt-p2v with nbdkit.

2017-01-26 Thread Richard W.M. Jones
--- p2v/Makefile.am | 1 + p2v/test-virt-p2v-nbdkit.sh | 80 + 2 files changed, 81 insertions(+) create mode 100755 p2v/test-virt-p2v-nbdkit.sh diff --git a/p2v/Makefile.am b/p2v/Makefile.am index 320d65a..0a2c2a8 100644 ---

[Libguestfs] [PATCH] Use srandom (time (NULL) + getpid ()) throughout.

2017-01-26 Thread Richard W.M. Jones
It avoids two programs which start at exactly the same time from having the same random number seed, which helps in some tests. --- edit/edit.c | 3 ++- fish/fish.c | 2 +- tests/mount-local/test-parallel-mount-local.c | 2 +- 3

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

2017-01-26 Thread Eric Blake
On 01/26/2017 09:16 AM, Richard W.M. Jones wrote: > It sounds like errno_is_reliable is an unknowable value. How would we > set it correctly for Perl (for example), in a way that would work for > all past and future Perl interpreters? errno is NEVER reliable after a non-C plugin, so we have a

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

2017-01-26 Thread Richard W.M. Jones
On Thu, Jan 26, 2017 at 08:08:46AM -0600, Eric Blake wrote: > On 01/26/2017 04:18 AM, Richard W.M. Jones wrote: > > On Wed, Jan 25, 2017 at 08:55:18PM -0600, Eric Blake wrote: > >> On 01/20/2017 02:16 PM, Eric Blake wrote: > >>> Reject rather than silently ignoring unknown client request flags. >

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

2017-01-26 Thread Eric Blake
On 01/26/2017 04:13 AM, Richard W.M. Jones wrote: > On Wed, Jan 25, 2017 at 08:42:34PM -0600, Eric Blake wrote: >> +eg. NULL or -1. If the call to C is omitted, then >> +the value of C will be used instead. > [...] >> +/* Grab the appropriate error value. >> + */ >> +static int >> +_get_error

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

2017-01-26 Thread Eric Blake
On 01/26/2017 04:18 AM, Richard W.M. Jones wrote: > On Wed, Jan 25, 2017 at 08:55:18PM -0600, Eric Blake wrote: >> On 01/20/2017 02:16 PM, Eric Blake wrote: >>> Reject rather than silently ignoring unknown client request flags. >>> >> >>> >>> + /* Validate flags */ >>> + if (flags &

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

2017-01-26 Thread Richard W.M. Jones
On Wed, Jan 25, 2017 at 08:55:18PM -0600, Eric Blake wrote: > 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:

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

2017-01-26 Thread Richard W.M. Jones
On Wed, Jan 25, 2017 at 08:42:35PM -0600, Eric Blake wrote: > 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()

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

2017-01-26 Thread Richard W.M. Jones
On Wed, Jan 25, 2017 at 08:42:36PM -0600, Eric Blake wrote: > 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

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

2017-01-26 Thread Richard W.M. Jones
On Wed, Jan 25, 2017 at 08:48:10PM -0600, Eric Blake wrote: > 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