From patchwork Wed Jan 21 12:57:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 431464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C7F31401AF for ; Wed, 21 Jan 2015 23:59:41 +1100 (AEDT) Received: from localhost ([::1]:47839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDusl-000406-N0 for incoming@patchwork.ozlabs.org; Wed, 21 Jan 2015 07:59:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDuqo-0000oV-Ix for qemu-devel@nongnu.org; Wed, 21 Jan 2015 07:57:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDuqk-0005r0-G3 for qemu-devel@nongnu.org; Wed, 21 Jan 2015 07:57:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDuqk-0005qf-69 for qemu-devel@nongnu.org; Wed, 21 Jan 2015 07:57:34 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0LCvVON002422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Jan 2015 07:57:31 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0LCvLLb015082; Wed, 21 Jan 2015 07:57:29 -0500 From: Laszlo Ersek To: qemu devel list , Paolo Bonzini , Peter Maydell , Laszlo Ersek Date: Wed, 21 Jan 2015 13:57:17 +0100 Message-Id: <1421845037-5374-3-git-send-email-lersek@redhat.com> In-Reply-To: <1421845037-5374-1-git-send-email-lersek@redhat.com> References: <1421845037-5374-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] signalfd(): modernize detection and use X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org qemu_signalfd() provides the (effects of the) Linux signalfd() syscall on platforms that lack it. However, the check for the availability of signalfd() in configure, and its use in qemu_signalfd() when it *is* available, are seriously outdated (they date back to 2010-2011). To wit, the SYS_signalfd-based check in configure can actually fail on at least modern aarch64 Linux systems that *do* have signalfd(). (SYS_signalfd is deprecated and has been replaced by SYS_signalfd4 (note the "4"). The signalfd() libc function selects the appropriate system call.) We should consider signalfd() accessible as a first class libc function on platforms that support it. Modernize the related parts in configure and "util/compatfd.c" (so that we end up with something similar to eventfd()'s detection). Signed-off-by: Laszlo Ersek --- configure | 11 ++++++++--- util/compatfd.c | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 5ea1014..de0d21c 100755 --- a/configure +++ b/configure @@ -3280,10 +3280,15 @@ fi # signalfd probe signalfd="no" cat > $TMPC << EOF -#include -#include +#include #include -int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); } +int main(void) +{ + sigset_t s; + + sigfillset(&s); + return signalfd(-1, &s, SFD_CLOEXEC); +} EOF if compile_prog "" "" ; then diff --git a/util/compatfd.c b/util/compatfd.c index e857150..7983391 100644 --- a/util/compatfd.c +++ b/util/compatfd.c @@ -17,7 +17,7 @@ #include "qemu/compatfd.h" #include "qemu/thread.h" -#include +#include struct sigfd_compat_info { @@ -99,9 +99,8 @@ int qemu_signalfd(const sigset_t *mask) #if defined(CONFIG_SIGNALFD) int ret; - ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8); + ret = signalfd(-1, mask, SFD_CLOEXEC); if (ret != -1) { - qemu_set_cloexec(ret); return ret; } #endif