[Libguestfs] [nbdkit PATCH 3/3] plugins: Match docs for .errno_is_preserved

Eric Blake eblake at redhat.com
Fri Aug 2 03:42:59 UTC 2019


Ever since commit 69ae137f, the docs claimed that we check
.errno_is_preserved == 1, but the code has checked for != 0.
Furthermore, the mention of .errno_is_preserved in the docs was rather
hidden; a new section will make it easier to add future knobs that
likewise affect the plugin as a whole and not an individual
connection.

Fixes: 69ae137f
Signed-off-by: Eric Blake <eblake at redhat.com>
---
 docs/nbdkit-plugin.pod | 16 ++++++++++++++++
 server/plugins.c       |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod
index c764f8b0..d778d6af 100644
--- a/docs/nbdkit-plugin.pod
+++ b/docs/nbdkit-plugin.pod
@@ -915,6 +915,22 @@ If there is an error, C<.cache> should call C<nbdkit_error> with an
 error message, and C<nbdkit_set_error> to record an appropriate error
 (unless C<errno> is sufficient), then return C<-1>.

+=head1 OTHER FIELDS
+
+The plugin struct also contains an integer field used as a
+boolean in C code, but unlikely to be exposed in other language
+bindings:
+
+=over 4
+
+=item C<.errno_is_preserved>
+
+This defaults to 0; if non-zero, nbdkit can reliably use the value of
+C<errno> when a callback reports failure, rather than the plugin
+having to call C<nbdkit_set_error>.
+
+=back
+
 =head1 THREADS

 Each nbdkit plugin must declare its maximum thread safety model by
diff --git a/server/plugins.c b/server/plugins.c
index 8eed2dd8..7da2329e 100644
--- a/server/plugins.c
+++ b/server/plugins.c
@@ -492,7 +492,7 @@ get_error (struct backend_plugin *p)
 {
   int ret = threadlocal_get_error ();

-  if (!ret && p->plugin.errno_is_preserved)
+  if (!ret && p->plugin.errno_is_preserved == 1)
     ret = errno;
   return ret ? ret : EIO;
 }
-- 
2.20.1




More information about the Libguestfs mailing list