From nobody Sat Apr 27 19:24:55 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=yadro.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534885945759188.06262872705338; Tue, 21 Aug 2018 14:12:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7872C308FB8B; Tue, 21 Aug 2018 21:12:22 +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 A0D2A30912F4; Tue, 21 Aug 2018 21:12:21 +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 C56411800540; Tue, 21 Aug 2018 21:12:18 +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 w7LLCHU7012694 for ; Tue, 21 Aug 2018 17:12:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D15752FD7; Tue, 21 Aug 2018 21:12:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2189677473 for ; Tue, 21 Aug 2018 21:12:13 +0000 (UTC) Received: from mta-01.yadro.com (mta-01.yadro.com [89.207.88.251]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3D43307D84D for ; Tue, 21 Aug 2018 21:12:12 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id D753D418F7 for ; Tue, 21 Aug 2018 21:12:10 +0000 (UTC) Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cc9NyarDK7Ad for ; Wed, 22 Aug 2018 00:12:05 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 899864120E for ; Wed, 22 Aug 2018 00:12:05 +0300 (MSK) Received: from localhost (172.17.128.60) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Wed, 22 Aug 2018 00:12:05 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received:received; s= mta-01; t=1534885925; x=1536700326; bh=Vdy2Tu3e6o5wTN0oO4fs5hZMF yNkWE21vfY3EMSSgmk=; b=O9U73cfQMjMj00vrMCkFE+g0nFUjk3aH10QDLTnwI Jr0WaTMzoDG+fuJ0gV43rjXGLp3FrekSjeJfIQn9TXMdmTjL/tidbQzKtCjOqx7N jZ+VyTRIJFQ7wF0LM25KM/hkNT0aWHXYyMwq09bu7sgIg4rFxa/sFepUQzckhSmR KI= X-Virus-Scanned: amavisd-new at yadro.com From: Roman Bolshakov To: Date: Wed, 22 Aug 2018 00:12:03 +0300 Message-ID: <20180821211203.99194-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.128.60] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 21 Aug 2018 21:12:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 21 Aug 2018 21:12:13 +0000 (UTC) for IP:'89.207.88.251' DOMAIN:'mta-01.yadro.com' HELO:'mta-01.yadro.com' FROM:'r.bolshakov@yadro.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, SPF_PASS) 89.207.88.251 mta-01.yadro.com 89.207.88.251 mta-01.yadro.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Roman Bolshakov Subject: [libvirt] [PATCH] util: eventpoll: Survive EBADF on macOS 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 21 Aug 2018 21:12:23 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fixes: https://www.redhat.com/archives/libvir-list/2017-January/msg00978.html QEMU is probed through monitor fd to check capabilities during libvirtd ini= t. The monitor fd is closed after probing by virQEMUCapsInitQMPCommandFree that calls virQEMUCapsInitQMPCommandAbort that calls qemuMonitorClose, the latter one notifies the event loop via an interrupt handle in qemuMonitorUnregister and after then closes monitor fd. There could be a case when interrupt is sent after eventLoop is unlocked but before virEventPollRunOnce blocks in poll, shortly before file descriptor is closed by qemuMonitorClose. Then poll receives closed monitor fd in fdset and returns EBADF. EBADF is not mentioned as a valid errno on macOS poll man-page but such behaviour can appear release-to-release, according to cpython: https://github.com/python/cpython/blob/master/Modules/selectmodule.c#L1161 The change also fixes the issue in qemucapabilitiestest. It returns Bad file descriptor message 25 times without the fix. Signed-off-by: Roman Bolshakov --- src/util/vireventpoll.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 13d278df13..6d19374c52 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -643,10 +643,18 @@ int virEventPollRunOnce(void) EVENT_DEBUG("Poll got error event %d", errno); if (errno =3D=3D EINTR || errno =3D=3D EAGAIN) goto retry; +#ifdef __APPLE__ + if (errno =3D=3D EBADF) { + ret =3D 0; + goto dispatch; + } +#endif virReportSystemError(errno, "%s", _("Unable to poll on file handles")); return -1; } + + dispatch: EVENT_DEBUG("Poll got %d event(s)", ret); =20 virMutexLock(&eventLoop.lock); --=20 2.15.2 (Apple Git-101.1) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list