nbd: Include error names in trace messages

NBD errors were originally sent over the wire based on Linux errno
values; but not all the world is Linux, and not all platforms share
the same values.  Since a number isn't very easy to decipher on all
platforms, update the trace messages to include the name of NBD
errors being sent/received over the wire.  Tweak the trace messages
to be at the point where we are using the NBD error, not the
translation to the host errno values.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20171027104037.8319-2-eblake@redhat.com>
This commit is contained in:
Eric Blake
2017-10-27 12:40:26 +02:00
parent abf6e752e5
commit e7a78d0eff
5 changed files with 30 additions and 4 deletions

View File

@@ -940,6 +940,8 @@ int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp)
reply->error = ldl_be_p(buf + 4);
reply->handle = ldq_be_p(buf + 8);
trace_nbd_receive_reply(magic, reply->error, nbd_err_lookup(reply->error),
reply->handle);
reply->error = nbd_errno_to_system_errno(reply->error);
if (reply->error == ESHUTDOWN) {
@@ -947,7 +949,6 @@ int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp)
error_setg(errp, "server shutting down");
return -EINVAL;
}
trace_nbd_receive_reply(magic, reply->error, reply->handle);
if (magic != NBD_SIMPLE_REPLY_MAGIC) {
error_setg(errp, "invalid magic (got 0x%" PRIx32 ")", magic);