mirror of https://gitee.com/openkylin/qemu.git
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:
parent
abf6e752e5
commit
e7a78d0eff
|
@ -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);
|
||||
|
|
23
nbd/common.c
23
nbd/common.c
|
@ -148,3 +148,26 @@ const char *nbd_cmd_lookup(uint16_t cmd)
|
|||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *nbd_err_lookup(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case NBD_SUCCESS:
|
||||
return "success";
|
||||
case NBD_EPERM:
|
||||
return "EPERM";
|
||||
case NBD_EIO:
|
||||
return "EIO";
|
||||
case NBD_ENOMEM:
|
||||
return "ENOMEM";
|
||||
case NBD_EINVAL:
|
||||
return "EINVAL";
|
||||
case NBD_ENOSPC:
|
||||
return "ENOSPC";
|
||||
case NBD_ESHUTDOWN:
|
||||
return "ESHUTDOWN";
|
||||
default:
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ const char *nbd_opt_lookup(uint32_t opt);
|
|||
const char *nbd_rep_lookup(uint32_t rep);
|
||||
const char *nbd_info_lookup(uint16_t info);
|
||||
const char *nbd_cmd_lookup(uint16_t info);
|
||||
const char *nbd_err_lookup(int err);
|
||||
|
||||
int nbd_drop(QIOChannel *ioc, size_t size, Error **errp);
|
||||
|
||||
|
|
|
@ -1227,7 +1227,8 @@ static int nbd_co_send_simple_reply(NBDClient *client,
|
|||
{.iov_base = data, .iov_len = len}
|
||||
};
|
||||
|
||||
trace_nbd_co_send_simple_reply(handle, nbd_err, len);
|
||||
trace_nbd_co_send_simple_reply(handle, nbd_err, nbd_err_lookup(nbd_err),
|
||||
len);
|
||||
set_be_simple_reply(&reply, nbd_err, handle);
|
||||
|
||||
return nbd_co_send_iov(client, iov, len ? 2 : 1, errp);
|
||||
|
|
|
@ -29,7 +29,7 @@ nbd_client_loop_ret(int ret, const char *error) "NBD loop returned %d: %s"
|
|||
nbd_client_clear_queue(void) "Clearing NBD queue"
|
||||
nbd_client_clear_socket(void) "Clearing NBD socket"
|
||||
nbd_send_request(uint64_t from, uint32_t len, uint64_t handle, uint16_t flags, uint16_t type, const char *name) "Sending request to server: { .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64 ", .flags = 0x%" PRIx16 ", .type = %" PRIu16 " (%s) }"
|
||||
nbd_receive_reply(uint32_t magic, int32_t error, uint64_t handle) "Got reply: { magic = 0x%" PRIx32 ", .error = % " PRId32 ", handle = %" PRIu64" }"
|
||||
nbd_receive_reply(uint32_t magic, int32_t error, const char *errname, uint64_t handle) "Got reply: { magic = 0x%" PRIx32 ", .error = %" PRId32 " (%s), handle = %" PRIu64" }"
|
||||
|
||||
# nbd/server.c
|
||||
nbd_negotiate_send_rep_len(uint32_t opt, const char *optname, uint32_t type, const char *typename, uint32_t len) "Reply opt=0x%" PRIx32 " (%s), type=0x%" PRIx32 " (%s), len=%" PRIu32
|
||||
|
@ -53,7 +53,7 @@ nbd_negotiate_success(void) "Negotiation succeeded"
|
|||
nbd_receive_request(uint32_t magic, uint16_t flags, uint16_t type, uint64_t from, uint32_t len) "Got request: { magic = 0x%" PRIx32 ", .flags = 0x%" PRIx16 ", .type = 0x%" PRIx16 ", from = %" PRIu64 ", len = %" PRIu32 " }"
|
||||
nbd_blk_aio_attached(const char *name, void *ctx) "Export %s: Attaching clients to AIO context %p\n"
|
||||
nbd_blk_aio_detach(const char *name, void *ctx) "Export %s: Detaching clients from AIO context %p\n"
|
||||
nbd_co_send_simple_reply(uint64_t handle, uint32_t error, int len) "Send simple reply: handle = %" PRIu64 ", error = %" PRIu32 ", len = %d"
|
||||
nbd_co_send_simple_reply(uint64_t handle, uint32_t error, const char *errname, int len) "Send simple reply: handle = %" PRIu64 ", error = %" PRIu32 " (%s), len = %d"
|
||||
nbd_co_receive_request_decode_type(uint64_t handle, uint16_t type, const char *name) "Decoding type: handle = %" PRIu64 ", type = %" PRIu16 " (%s)"
|
||||
nbd_co_receive_request_payload_received(uint64_t handle, uint32_t len) "Payload received: handle = %" PRIu64 ", len = %" PRIu32
|
||||
nbd_co_receive_request_cmd_write(uint32_t len) "Reading %" PRIu32 " byte(s)"
|
||||
|
|
Loading…
Reference in New Issue