search for: nbdkit_set_error

Displaying 20 results from an estimated 157 matches for "nbdkit_set_error".

2017 Jan 26
2
Re: [nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function
On Wed, Jan 25, 2017 at 08:42:34PM -0600, Eric Blake wrote: > +eg. NULL or -1. If the call to C<nbdkit_set_error> is omitted, then > +the value of C<errno> will be used instead. [...] > +/* Grab the appropriate error value. > + */ > +static int > +_get_error (void) > +{ > + int err = errno; > + int ret = tls_get_error (); > + > + if (!ret) > + ret = err ? err :...
2017 Jan 26
0
Re: [nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function
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<nbdkit_set_error> is omitted, then >> +the value of C<errno> will be used instead. > [...] >> +/* Grab the appropriate error value. >> + */ >> +static int >> +_get_error (void) >> +{ >> + int err = errno; >> + int ret = tls_get_error (); >> + >&...
2017 Jan 26
1
Re: [nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function
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<nbdkit_set_error> is omitted, then > >> +the value of C<errno> will be used instead. > > [...] > >> +/* Grab the appropriate error value. > >> + */ > >> +static int > >> +_get_error (void) > >> +{ > >> + int err = errno; > >> +...
2017 Jan 26
0
[nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function
...n.pod @@ -143,14 +143,23 @@ is called once just before the plugin is unloaded from memory. =head1 ERROR HANDLING If there is an error in the plugin, the plugin should call -C<nbdkit_error> with the error message, and then return an error -indication from the callback, eg. NULL or -1. +C<nbdkit_set_error> to influence the error code that will be set to +the client, then C<nbdkit_error> to report an error message; the +plugin should then return an error indication from the callback, +eg. NULL or -1. If the call to C<nbdkit_set_error> is omitted, then +the value of C<errno> will...
2018 Jan 27
0
nbdkit filter error handling
I've given some more thoughts to error handling in nbdkit filters, and am writing this while it is still fresh on my mind (even though I won't have time to code any of it until next week). Right now, plugins are allowed to call either nbdkit_set_error OR to leave a value in errno; the latter works only if errno_is_preserved was set. If a plugin returns -1 but does not set an error through either method, then nbdkit assumes EIO as the error value. But filters may want/need to perform error recovery (perhaps recognizing an ENOSPC on write, by re...
2017 Jan 26
0
[nbdkit PATCH v2 5/6] python: Expose nbdkit_set_error to python script
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 <eblake@redhat.com> --- plugins/python/nbdkit-python-plugin.pod | 27 +++++++++++++++++++++++---- plugins/python/python.c | 18 ++++++++++++++++++ 2 files changed, 41 inse...
2018 Feb 01
1
Re: [nbdkit PATCH v2 1/3] backend: Rework internal/filter error return semantics
On Wed, Jan 31, 2018 at 09:26:37PM -0600, Eric Blake wrote: > Previously, we let a plugin set an error in either thread-local > storage (nbdkit_set_error()) or errno, then connections.c would > decode which error to use. But with filters in the mix, it is > very difficult for a filter to know what error was set by the > plugin (particularly since nbdkit_set_error() has no public > counterpart for reading the thread-local storage). What...
2017 Jan 27
6
[nbdkit PATCH v3 0/4] bind .zero to Python
...mplicit 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 errno from non-C plugins plugins: Add new nbdkit_set_error() utility function python: Expose nbdkit_set_error to python script python: Support zero callback docs/nbdkit-plugin.pod | 64 +++++++++++++++++++++++---- include/nbdkit-plugin.h | 14 +++++- plugins/ocaml/nbdkit-ocaml-plugin.pod | 11 +++++ plugins/ocaml/oc...
2017 Jan 26
10
[nbdkit PATCH v2 0/6] bind .zero to Python
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). I could not easily find out how to register a C function callable from perl bindings, and have not...
2020 Jun 06
2
[nbdkit] About the Rust bindings
...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/plu...
2019 Apr 24
0
[PATCH nbdkit 1/2] server: extents: Set errno on error from nbdkit_add_extent.
...e51c68..6aeaa7b 100644 --- a/docs/nbdkit-filter.pod +++ b/docs/nbdkit-filter.pod @@ -571,7 +571,8 @@ the end, but for filters which adjust offsets, they should pass in the adjusted offset. On error this function can return C<NULL>. In this case it calls -C<nbdkit_error> and/or C<nbdkit_set_error> as required. +C<nbdkit_error> and/or C<nbdkit_set_error> as required. C<errno> will +be set to a suitable value. void nbdkit_extents_free (struct nbdkit_extents *); diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod index 272ec67..e9dc34f 100644 --- a/docs/nbd...
2017 Feb 06
0
[PATCH 1/2] Define .errno_is_preserved constant instead of a .errno_is_reliable callback.
...a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod index 3611244..4b364f3 100644 --- a/docs/nbdkit-plugin.pod +++ b/docs/nbdkit-plugin.pod @@ -147,10 +147,16 @@ C<nbdkit_error> to report an error message; additionally, if the callback is involved in serving data, the plugin should call C<nbdkit_set_error> to influence the error code that will be sent to the client. These two functions can be called in either order. Then, -the callback should return the appropriate error indication, eg. NULL -or -1. If the call to C<nbdkit_set_error> is omitted while serving -data, then the C<.errno_...
2017 Jan 31
4
[nbdkit PATCH v3 0/3] bind .zero to Perl
...39;t decided if patch 1 of the python series should change OCaml to report errno as reliable or not, but perhaps we can commit that patch as-is now and then touch things up further when we actually get set_error and zero working in OCaml. Eric Blake (3): perl: Allow use of modules perl: Expose nbdkit_set_error to perl script perl: Support zero callback plugins/perl/example.pl | 16 +++++++++ plugins/perl/nbdkit-perl-plugin.pod | 56 +++++++++++++++++++++++++++++--- plugins/perl/perl.c | 65 ++++++++++++++++++++++++++++++++++++- 3 files changed, 131 insertions(+), 6 deletio...
2017 Feb 02
3
[nbdkit PATCH 0/2] Ruby bindings for .zero
Similar to python and perl. But MUCH easier (especially considering that this is the first time I've every tried to run Ruby). I even had fun making set_error() polymorphic. Eric Blake (2): ruby: Expose nbdkit_set_error to ruby script ruby: Support zero callback plugins/ruby/example.rb | 11 ++++++++ plugins/ruby/nbdkit-ruby-plugin.pod | 54 +++++++++++++++++++++++++++++++++---- plugins/ruby/ruby.c | 51 +++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 5 delet...
2019 Jun 25
2
Re: [libnbd PATCH v2 2/5] states: Wire in a read callback
On Thu, Jun 20, 2019 at 08:45:05PM -0500, Eric Blake wrote: > If any callback fails, and if no prior error was set, then the > callback's failure becomes the failure reason for the overall > read. (Note that this is different from the block status callback, > which for now quits using the callback on subsequent chunks if an > earlier chunk failed - we may decide to change one or
2017 Feb 06
3
[PATCH nbdkit 0/2] Change .errno_is_reliable function to .errno_is_preserved constant.
See patch 1 for rationale.
2019 Aug 16
2
Re: [nbdkit PATCH 1/2] rust: Implement can_cache
...ld apply on top to prevent all of our _named fields from being overwritten after the initial construction with default values). And of course, if you want to actually implement extents, and figure out how to expose C-based nbdkit functions to be called by Rust code, be my guest (for .zero, we need nbdkit_set_error(), for extents, we need nbdkit_add_extent(), and then we have several other utility functions like nbdkit_realpath() that could be useful). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 5/5] server: Indirect slow path, non-self-contained functions through the server.
...); @@ -473,6 +474,7 @@ extern int backend_cache (struct backend *b, extern struct backend *plugin_register (size_t index, const char *filename, void *dl, struct nbdkit_plugin *(*plugin_init) (void)) __attribute__((__nonnull__ (2, 3, 4))); +extern void do_nbdkit_set_error (int err); /* filters.c */ extern struct backend *filter_register (struct backend *next, size_t index, @@ -515,6 +517,11 @@ extern void *threadlocal_buffer (size_t size); extern void threadlocal_set_conn (struct connection *conn); extern struct connection *threadlocal_get_conn (void); +/* p...
2017 Nov 12
6
[nbdkit PATCH] nbd: Add new nbd forwarding plugin
...e = htobe32 (type), + .handle = htobe64 (h->cookie), + .offset = htobe64 (offset), + .count = htobe32 (count), + }; + int r; + + /* TODO full parallel support requires tracking cookies for handling + out-of-order responses */ + *cookie = h->cookie++; + if (h->dead) { + nbdkit_set_error (ESHUTDOWN); + return -1; + } + nbdkit_debug ("sending request with type %d and cookie %" PRIu64, type, + *cookie); + r = write_full (h->fd, &req, sizeof req); + if (r < 0) + h->dead = true; + return r; +} + +static int nbd_reply (struct handle *h, uint64_t cookie...
2019 Apr 24
4
[PATCH nbdkit 2/2] filters: Be careful to set *err if nbdkit_add_extent or nbdkit_extents_new fail.
This fix isn't exhaustive but it fixes some obvious problems in the filters. Rich.