On Tue, Jul 23, 2024 at 04:19:43PM +0100, Richard W.M. Jones wrote:
Currently nbdkit only sends an error code (like NBD_REP_ERR_*) and
possibly an errno (NBD_E*) back to the NBD client. This loses a lot
of useful information, meaning callers can only find out what really
went wrong by looking at server-side logs, which of course might not
be available or easy to access.
This change sends informational error messages back to the NBD client ...
in most cases. There are some caveats, see patch 3/3.
One thing I forgot to add is that libnbd doesn't actually print the
error message. Instead it is sent to debug output only.
For example running nbdinfo without debug prints the generic error:
$ nbdkit --log=null \
eval open=' echo EPERM Go Away >&2; exit 1 ' get_size=' echo 100
' \
--run 'nbdinfo "$uri"'
nbdinfo: nbd_opt_go: server replied with error to opt_go request: No such file or
directory for the default export
nbdinfo: suggestion: to list all exports on the server, use --list
protocol: newstyle-fixed without TLS, using structured packets
With debug, the error message appears buried in libnbd debug output:
$ nbdkit --log=null \
eval open=' echo EPERM Go Away >&2; exit 1 ' get_size=' echo 100
' \
--run 'LIBNBD_DEBUG=1 nbdinfo "$uri"'
...
libnbd: debug: nbd1: nbd_opt_info: handshake: server error message:
/tmp/nbdkitkYqOww/open: Go Away
...
(
https://gitlab.com/nbdkit/libnbd/-/blob/9d1a65d0e653e0411622ebb9859c4f969...)
I will try to solve this one in another patch series.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW