examples: copy-libev.c: Fix error handling
This example failed to check the *error parameter to the completion and extent callbacks. - If the source NBD server failed a read, we wrote stale data from the request buffer to the destination image, corrupting the image. - If the destination NBD server failed a write or zero command, we ignored the error, leaving previous content on the destination image, corrupting the image. - Error in the extents callbacks were ignored. I'm not sure if this was a real problem, but it is a very bad example. In all cases, the copy would end with zero exit code creating a corrupted image. Fixed by failing the copy if read, write, zero commands completed with non-zero *error parameter. If an extent callback completed with non-zero *error, we log the error and abort the callback, leaving the extents array as NULL. If extents completion callback completed with non-zero *error we don't need to check it, since we already handle a NULL extents array by disabling can_extents. Here is an example failure: $ ./copy-libev nbd+unix:///?socket=/tmp/src.sock nbd+unix:///?socket=/tmp/dst.sock copy-libev: r0: read failed: Input/output error $ echo $? 1 Signed-off-by:Nir Soffer <nsoffer@redhat.com>