Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KjgsI-0002uw-5x for qemu-devel@nongnu.org; Sat, 27 Sep 2008 16:58:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KjgsH-0002uk-LK for qemu-devel@nongnu.org; Sat, 27 Sep 2008 16:58:45 -0400 Received: from [199.232.76.173] (port=58958 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KjgsH-0002uh-EC for qemu-devel@nongnu.org; Sat, 27 Sep 2008 16:58:45 -0400 Received: from savannah.gnu.org ([199.232.41.3]:56813 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KjgsH-0006Pj-0p for qemu-devel@nongnu.org; Sat, 27 Sep 2008 16:58:45 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KjgsG-0000wI-Fh for qemu-devel@nongnu.org; Sat, 27 Sep 2008 20:58:44 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KjgsG-0000wE-7Q for qemu-devel@nongnu.org; Sat, 27 Sep 2008 20:58:44 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Sat, 27 Sep 2008 20:58:44 +0000 Subject: [Qemu-devel] [5334] Make compatfd fallback more robust Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5334 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5334 Author: aliguori Date: 2008-09-27 20:58:43 +0000 (Sat, 27 Sep 2008) Log Message: ----------- Make compatfd fallback more robust Be more friendly when signalfd() fails, and also add configure checks to detect that syscall(SYS_signalfd) actually works. malc pointed out that some installs do not have /usr/include/linux headers that are in sync with the glibc headers so why SYS_signalfd is defined, it's #defined to _NR_signalfd which is not defined in the /usr/include/linux header. While this is a distro bug, it doesn't hurt to do a more thorough job in detection. Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/block-raw-posix.c trunk/compatfd.c trunk/configure Modified: trunk/block-raw-posix.c =================================================================== --- trunk/block-raw-posix.c 2008-09-27 20:41:11 UTC (rev 5333) +++ trunk/block-raw-posix.c 2008-09-27 20:58:43 UTC (rev 5334) @@ -584,6 +584,10 @@ s->first_aio = NULL; s->fd = qemu_signalfd(&mask); + if (s->fd == -1) { + fprintf(stderr, "failed to create signalfd\n"); + return -errno; + } fcntl(s->fd, F_SETFL, O_NONBLOCK); Modified: trunk/compatfd.c =================================================================== --- trunk/compatfd.c 2008-09-27 20:41:11 UTC (rev 5333) +++ trunk/compatfd.c 2008-09-27 20:58:43 UTC (rev 5334) @@ -100,11 +100,11 @@ int qemu_signalfd(const sigset_t *mask) { -#if defined(SYS_signalfd) +#if defined(CONFIG_signalfd) int ret; ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8); - if (!(ret == -1 && errno == ENOSYS)) + if (ret != -1) return ret; #endif @@ -113,15 +113,14 @@ int qemu_eventfd(int *fds) { -#if defined(SYS_eventfd) +#if defined(CONFIG_eventfd) int ret; ret = syscall(SYS_eventfd, 0); if (ret >= 0) { fds[0] = fds[1] = ret; return 0; - } else if (!(ret == -1 && errno == ENOSYS)) - return ret; + } #endif return pipe(fds); Modified: trunk/configure =================================================================== --- trunk/configure 2008-09-27 20:41:11 UTC (rev 5333) +++ trunk/configure 2008-09-27 20:58:43 UTC (rev 5334) @@ -110,6 +110,8 @@ aio="yes" nptl="yes" mixemu="no" +signalfd="no" +eventfd="no" # OS specific targetos=`uname -s` @@ -901,6 +903,33 @@ fi fi +########################################## +# signalfd probe +cat > $TMPC << EOF +#define _GNU_SOURCE +#include +#include +#include +int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); } +EOF + +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + signalfd=yes +fi + +########################################## +# eventfd probe +cat > $TMPC << EOF +#define _GNU_SOURCE +#include +#include +int main(void) { return syscall(SYS_eventfd, 0); } +EOF + +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + eventfd=yes +fi + # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then @@ -1229,6 +1258,12 @@ echo "#define CONFIG_AIO 1" >> $config_h echo "CONFIG_AIO=yes" >> $config_mak fi +if test "$signalfd" = "yes" ; then + echo "#define CONFIG_signalfd 1" >> $config_h +fi +if test "$eventfd" = "yes" ; then + echo "#define CONFIG_eventfd 1" >> $config_h +fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then