[PATCH 3/7] vhost: improve socket layer logs
Maxime Coquelin
maxime.coquelin at redhat.com
Tue Jan 25 11:44:43 CET 2022
On 1/4/22 15:47, David Marchand wrote:
> On Thu, Dec 23, 2021 at 9:37 AM Maxime Coquelin
> <maxime.coquelin at redhat.com> wrote:
>>
>> This patch adds the Vhost socket path whenever possible in
>> order to make debugging possible when multiple Vhost
>> devices are in use.
>
> This patch could go after patch 5 so that we have a dev->ifname
> available instead of fd.
Right, I'm doing this with also doing the same for send_vhost_message.
>
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
>> ---
>> lib/vhost/socket.c | 129 ++++++++++++++++++---------------------------
>> 1 file changed, 51 insertions(+), 78 deletions(-)
>>
>> diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
>> index 82963c1e6d..fd6b3a3ee4 100644
>> --- a/lib/vhost/socket.c
>> +++ b/lib/vhost/socket.c
>> @@ -124,12 +124,12 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
>> ret = recvmsg(sockfd, &msgh, 0);
>> if (ret <= 0) {
>> if (ret)
>> - VHOST_LOG_CONFIG(ERR, "recvmsg failed\n");
>> + VHOST_LOG_CONFIG(ERR, "recvmsg failed (fd %d)\n", sockfd);
>
> strerror(errno) ?
Right, I also add it for sendmsg() et fcntl().
>
>> return ret;
>> }
>>
>> if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) {
>> - VHOST_LOG_CONFIG(ERR, "truncated msg\n");
>> + VHOST_LOG_CONFIG(ERR, "truncated msg (fd %d)\n", sockfd);
>> return -1;
>> }
>>
>> @@ -192,7 +192,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)
>> } while (ret < 0 && errno == EINTR);
>>
>> if (ret < 0) {
>> - VHOST_LOG_CONFIG(ERR, "sendmsg error\n");
>> + VHOST_LOG_CONFIG(ERR, "sendmsg error (fd %d)\n", sockfd);
>
> strerror(errno) ?
>
> There is an extra space before "sendmsg error...
Fixed.
>
> In this same function, we have a log with no context / fd logged:
> VHOST_LOG_CONFIG(ERR, "cmsg == NULL\n");
> I'd add sockfd (and/or dev->ifname if available) in this log.
Done, with adding the socket path.
>> return ret;
>> }
>>
>
>
> The rest lgtm.
>
>
More information about the dev
mailing list