Re: [Libguestfs] [nbdkit PATCH 2/2] plugins: Consistent error handling on FUA

2018-02-14 Thread Richard W.M. Jones
ACK series.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


[Libguestfs] [nbdkit PATCH 2/2] plugins: Consistent error handling on FUA

2018-02-13 Thread Eric Blake
We document that a plugin callback should return 0 on success, but
other places in the code treat all values other than -1 as success
(perhaps we should treat all negative values as errors, instead of
exactly -1, but that may break binary back-compatibility).  However,
when reworking where FUA fallback occurs, we introduced a subtle
change: if a plugin returns a positive value on success, and the
client requested FUA, we ended up reporting success to the client
without performing FUA.

Fixes: 4f37c64ffdd42fab5c5d9c6157db396b60866a7a
Signed-off-by: Eric Blake 
---
 src/plugins.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/plugins.c b/src/plugins.c
index 699e9c5..1b0816c 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -412,7 +412,7 @@ plugin_pwrite (struct backend *b, struct connection *conn,
 errno = EROFS;
 return -1;
   }
-  if (r == 0 && fua) {
+  if (r != -1 && fua) {
 assert (p->plugin.flush);
 r = plugin_flush (b, conn, 0);
   }
@@ -439,7 +439,7 @@ plugin_trim (struct backend *b, struct connection *conn,
 errno = EINVAL;
 return -1;
   }
-  if (r == 0 && fua) {
+  if (r != -1 && fua) {
 assert (p->plugin.flush);
 r = plugin_flush (b, conn, 0);
   }
@@ -503,7 +503,7 @@ plugin_zero (struct backend *b, struct connection *conn,
   errno = err;

  done:
-  if (!result && fua) {
+  if (result != -1 && fua) {
 assert (p->plugin.flush);
 result = plugin_flush (b, conn, 0);
   }
-- 
2.14.3

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs