From b8ac3e8acdfd6bcb81204e160d652b681fd05052 Mon Sep 17 00:00:00 2001 From: Dayu Liu Date: Thu, 21 May 2020 09:22:00 +0800 Subject: [PATCH] read_fd_message: distinguish prints of log message When VM shutdown there will be an error message 'VHOST_CONFIG: recvmsg failed' printed. The return value of recvmsg will be 0 when the peer has performed an orderly shutdown, or -1 if an error occurred. So adding logs to distinguish these two different situations to avoid confusing and to hint accurately. Signed-off-by: Dayu Liu Change-Id: Ia4b806a11d3c6ddf076c61d1caad4fa7b16fb9b5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2557 Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Darek Stojaczyk Tested-by: SPDK CI Jenkins --- lib/rte_vhost/socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rte_vhost/socket.c b/lib/rte_vhost/socket.c index 2b2716a5d5..ec923518be 100644 --- a/lib/rte_vhost/socket.c +++ b/lib/rte_vhost/socket.c @@ -137,7 +137,10 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num) ret = recvmsg(sockfd, &msgh, 0); if (ret <= 0) { - RTE_LOG(ERR, VHOST_CONFIG, "recvmsg failed\n"); + if (ret) + RTE_LOG(ERR, VHOST_CONFIG, "recvmsg failed, %s\n", strerror(errno)); + else + RTE_LOG(INFO, VHOST_CONFIG, "peer closed\n"); return ret; }