From nobody Sat Apr 27 09:48:15 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 1535014212654443.72120863727537; Thu, 23 Aug 2018 01:50:12 -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 41F85308FBA2; Thu, 23 Aug 2018 08:50:10 +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 D6553309132E; Thu, 23 Aug 2018 08:50:09 +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 4EE1F181A12E; Thu, 23 Aug 2018 08:50:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7N8ncBl006297 for ; Thu, 23 Aug 2018 04:49:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 99E55308BDA4; Thu, 23 Aug 2018 08:49:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90C49308BDA0 for ; Thu, 23 Aug 2018 08:49:38 +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 7589D3082144 for ; Thu, 23 Aug 2018 08:49:37 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id E9A8F418FF for ; Thu, 23 Aug 2018 08:49:35 +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 h0u_MF6cWa-Q for ; Thu, 23 Aug 2018 11:49:34 +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 B55EF404CD for ; Thu, 23 Aug 2018 11:49:34 +0300 (MSK) Received: from localhost (172.17.1.90) 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; Thu, 23 Aug 2018 11:49:34 +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=1535014174; x=1536828575; bh=68fklNnHpT1DlN5MH08W6tXGR YMj5GPIJnkqy4rIZmw=; b=hML5iscS5f2YK4NUlK5XIYuOciJ6VgT4QMurjPNQL tfizZTPU+Sl+RYIujqFAg6QlWoIRZxG9P+G8LR48MoMZdH6OIKJWEfIHsyUFw4aa Vemq1ou0fLiuWDP2tg1TDUP54Sq6TJSZFLw7zQ3zH6qtKTX+ie5Amvb0ZOB13fiy Ls= X-Virus-Scanned: amavisd-new at yadro.com From: Roman Bolshakov To: Date: Thu, 23 Aug 2018 11:49:32 +0300 Message-ID: <20180823084932.37416-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.1.90] 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.42]); Thu, 23 Aug 2018 08:49:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 23 Aug 2018 08:49:37 +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.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Roman Bolshakov Subject: [libvirt] [PATCH v2] 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]); Thu, 23 Aug 2018 08:50:11 +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 --- Changes since v1: * Don't go through dispatch code on EBADF src/util/vireventpoll.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 13d278df13..7d0ffd4113 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -643,6 +643,12 @@ 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) { + virMutexLock(&eventLoop.lock); + goto stop; + } +#endif virReportSystemError(errno, "%s", _("Unable to poll on file handles")); return -1; @@ -660,6 +666,7 @@ int virEventPollRunOnce(void) virEventPollCleanupTimeouts(); virEventPollCleanupHandles(); =20 + stop: eventLoop.running =3D 0; virMutexUnlock(&eventLoop.lock); return 0; --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list