From nobody Sat May 4 04:30:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 14897657060235.007635253775561; Fri, 17 Mar 2017 08:48:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 982A283F45; Fri, 17 Mar 2017 15:48:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C441BFA6C; Fri, 17 Mar 2017 15:48:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A5314BB74; Fri, 17 Mar 2017 15:48:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2HFlvHf031546 for ; Fri, 17 Mar 2017 11:47:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A43DBFA63; Fri, 17 Mar 2017 15:47:57 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA22A627DD; Fri, 17 Mar 2017 15:47:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 982A283F45 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 982A283F45 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 17 Mar 2017 16:48:49 +0100 Message-Id: <55534f63a59d9253d98b77430413c2366f3cce75.1489765683.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/3] rpc: socket: Add possibility to suppress errors on read hangup X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 17 Mar 2017 15:48:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In some cases a read error due to connection hangup is expected. This patch adds a flag that removes the logging of a virError in such case. --- src/rpc/virnetsocket.c | 33 +++++++++++++++++++++++++++------ src/rpc/virnetsocket.h | 2 ++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 325a7c7cf..4d1dc6446 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -82,6 +82,7 @@ struct _virNetSocket { int errfd; bool client; bool ownsFd; + bool quietEOF; /* Event callback fields */ virNetSocketIOFunc func; @@ -1792,12 +1793,18 @@ static ssize_t virNetSocketReadWire(virNetSocketPtr= sock, char *buf, size_t len) _("Cannot recv data")); ret =3D -1; } else if (ret =3D=3D 0) { - if (errout) - virReportSystemError(EIO, - _("End of file while reading data: %s"), = errout); - else - virReportSystemError(EIO, "%s", - _("End of file while reading data")); + if (sock->quietEOF) { + VIR_DEBUG("socket=3D'%p' EOF while reading: errout=3D'%s'", + socket, NULLSTR(errout)); + } else { + if (errout) + virReportSystemError(EIO, + _("End of file while reading data: %s= "), + errout); + else + virReportSystemError(EIO, "%s", + _("End of file while reading data")); + } ret =3D -1; } @@ -2233,3 +2240,17 @@ void virNetSocketClose(virNetSocketPtr sock) virObjectUnlock(sock); } + + +/** + * virNetSocketSetQuietEOF: + * @sock: socket object pointer + * + * Disables reporting I/O errors as a virError when @socket is closed while + * reading data. + */ +void +virNetSocketSetQuietEOF(virNetSocketPtr sock) +{ + sock->quietEOF =3D true; +} diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h index 56c75c030..1e75ee62b 100644 --- a/src/rpc/virnetsocket.h +++ b/src/rpc/virnetsocket.h @@ -143,6 +143,8 @@ int virNetSocketGetSELinuxContext(virNetSocketPtr sock, int virNetSocketSetBlocking(virNetSocketPtr sock, bool blocking); +void virNetSocketSetQuietEOF(virNetSocketPtr sock); + ssize_t virNetSocketRead(virNetSocketPtr sock, char *buf, size_t len); ssize_t virNetSocketWrite(virNetSocketPtr sock, const char *buf, size_t le= n); --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:30:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 148976568256346.757568169074716; Fri, 17 Mar 2017 08:48:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E444AC04BD34; Fri, 17 Mar 2017 15:48:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A97755DC1D; Fri, 17 Mar 2017 15:48:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 604391853D10; Fri, 17 Mar 2017 15:48:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2HFm0vh031560 for ; Fri, 17 Mar 2017 11:48:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35C23BFA68; Fri, 17 Mar 2017 15:48:00 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9B0B62926; Fri, 17 Mar 2017 15:47:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E444AC04BD34 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E444AC04BD34 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 17 Mar 2017 16:48:50 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 2/3] rpc: serverclient: Add option to suppress errors on EOF X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Mar 2017 15:48:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The protocol may not use an explicit API to close the connection and just close the socket instead. Add option to suppress errors in such case. --- src/rpc/virnetserverclient.c | 13 +++++++++++++ src/rpc/virnetserverclient.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 81da82cab..85857bc3e 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -1637,3 +1637,16 @@ virNetServerClientGetInfo(virNetServerClientPtr clie= nt, virObjectUnlock(client); return ret; } + + +/** + * virNetServerClientSetQuietEOF: + * + * Don't report errors for protocols that close connection by hangup of the + * socket rather than calling an API to close it. + */ +void +virNetServerClientSetQuietEOF(virNetServerClientPtr client) +{ + virNetSocketSetQuietEOF(client->sock); +} diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index a53cc00b2..e45c78882 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -152,4 +152,6 @@ int virNetServerClientGetInfo(virNetServerClientPtr cli= ent, bool *readonly, char **sock_addr, virIdentityPtr *identity); +void virNetServerClientSetQuietEOF(virNetServerClientPtr client); + #endif /* __VIR_NET_SERVER_CLIENT_H__ */ --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:30:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1489765711100144.9494482505329; Fri, 17 Mar 2017 08:48:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EEDE64D8A; Fri, 17 Mar 2017 15:48:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45A0653CF5; Fri, 17 Mar 2017 15:48:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EFA315ED67; Fri, 17 Mar 2017 15:48:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2HFm1WB031567 for ; Fri, 17 Mar 2017 11:48:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 335A2BFA6A; Fri, 17 Mar 2017 15:48:01 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 839C3BFA68; Fri, 17 Mar 2017 15:48:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6EEDE64D8A Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6EEDE64D8A From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 17 Mar 2017 16:48:51 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/3] (log|lock)daemon: Don't spam logs with IO error messages after client disconnects X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 17 Mar 2017 15:48:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The log and lock protocol don't have an extra handshake to close the connection. Instead they just close the socket. Unfortunately that resulted into a lot of spurious garbage logged to the system log files: 2017-03-17 14:00:09.730+0000: 4714: error : virNetSocketReadWire:1800 : End= of file while reading data: Input/output error or in the journal as: Mar 13 16:19:33 xxxx virtlogd[32360]: End of file while reading data: Input= /output error Use the new facility in the netserverclient to suppress the IO error report from the virNetSocket layer. --- src/locking/lock_daemon.c | 3 +++ src/logging/log_daemon.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 1c94ddd05..12485e966 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -712,6 +712,9 @@ virLockDaemonClientNew(virNetServerClientPtr client, } } + /* there's no closing handshake in the locking protocol */ + virNetServerClientSetQuietEOF(client); + return priv; error: diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 5997cce9d..d878efa63 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -572,6 +572,9 @@ virLogDaemonClientNew(virNetServerClientPtr client, } } + /* there's no closing handshake in the logging protocol */ + virNetServerClientSetQuietEOF(client); + return priv; error: --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list