From nobody Thu May 2 21:28:09 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 1492531560617940.4565497380707; Tue, 18 Apr 2017 09:06:00 -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 7496837EE1; Tue, 18 Apr 2017 16:05:57 +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 060D4779EC; Tue, 18 Apr 2017 16:05:56 +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 52BB718523C6; Tue, 18 Apr 2017 16:05:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3IG5pwt017859 for ; Tue, 18 Apr 2017 12:05:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF281C90BA; Tue, 18 Apr 2017 16:05:51 +0000 (UTC) Received: from t460.redhat.com (ovpn-117-240.ams2.redhat.com [10.36.117.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1CC2C90A6; Tue, 18 Apr 2017 16:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7496837EE1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 7496837EE1 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 18 Apr 2017 17:05:46 +0100 Message-Id: <20170418160546.30666-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] Fix error reporting when poll returns POLLHUP/POLLERR 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.29]); Tue, 18 Apr 2017 16:05:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the RPC client event loop code, if poll() returns only a POLLHUP or POLLERR status, then we end up reporting a bogus error message: error: failed to connect to the hypervisor error: An error occurred, but the cause is unknown We do actually report an error, but we virNetClientMarkClose method has already captured the error status before we report it, so the real error gets thrown away. The key fix is to report the error before calling virNetClientMarkClose(). In changing this, we also split out reporting of POLLHUP vs POLLERR to make any future bugs easier to diagnose. Signed-off-by: Daniel P. Berrange --- src/rpc/virnetclient.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 5174614..c959747 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1743,10 +1743,16 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, if (error) goto error; =20 - if (fds[0].revents & (POLLHUP | POLLERR)) { + if (fds[0].revents & POLLHUP) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("received hangup event on socket")); virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_EOF); + goto error; + } + if (fds[0].revents & POLLERR) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("received hangup / error event on socket")); + _("received error event on socket")); + virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR); goto error; } } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list