From patchwork Fri Sep 6 15:38:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 273263 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7C1FA2C0111 for ; Sat, 7 Sep 2013 02:22:30 +1000 (EST) Received: from localhost ([::1]:38447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHyD9-0000YQ-5q for incoming@patchwork.ozlabs.org; Fri, 06 Sep 2013 11:44:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHy8Z-0004pT-2j for qemu-devel@nongnu.org; Fri, 06 Sep 2013 11:40:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHy8T-0005BM-1N for qemu-devel@nongnu.org; Fri, 06 Sep 2013 11:39:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHy8S-0005B6-PJ for qemu-devel@nongnu.org; Fri, 06 Sep 2013 11:39:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r86FdglF012844 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Sep 2013 11:39:42 -0400 Received: from localhost (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r86FdfAd010500; Fri, 6 Sep 2013 11:39:41 -0400 From: Stefan Hajnoczi To: Date: Fri, 6 Sep 2013 17:38:40 +0200 Message-Id: <1378481953-23099-10-git-send-email-stefanha@redhat.com> In-Reply-To: <1378481953-23099-1-git-send-email-stefanha@redhat.com> References: <1378481953-23099-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , Alex Bligh , Anthony Liguori Subject: [Qemu-devel] [PULL 09/42] aio / timers: fix build of test/test-aio.c on non-linux platforms 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 From: Alex Bligh tests/test-aio.c used pipe2 which is Linux only. Use qemu_pipe and qemu_set_nonblock for portabillity. Addition of O_CLOEXEC is a harmless bonus. Signed-off-by: Alex Bligh Signed-off-by: Stefan Hajnoczi --- tests/test-aio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test-aio.c b/tests/test-aio.c index 532a1de..c4fe0fc 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -13,6 +13,7 @@ #include #include "block/aio.h" #include "qemu/timer.h" +#include "qemu/sockets.h" AioContext *ctx; @@ -375,7 +376,10 @@ static void test_timer_schedule(void) /* aio_poll will not block to wait for timers to complete unless it has * an fd to wait on. Fixing this breaks other tests. So create a dummy one. */ - g_assert(!pipe2(pipefd, O_NONBLOCK)); + g_assert(!qemu_pipe(pipefd)); + qemu_set_nonblock(pipefd[0]); + qemu_set_nonblock(pipefd[1]); + aio_set_fd_handler(ctx, pipefd[0], dummy_io_handler_read, NULL, NULL); aio_poll(ctx, false); @@ -716,7 +720,10 @@ static void test_source_timer_schedule(void) /* aio_poll will not block to wait for timers to complete unless it has * an fd to wait on. Fixing this breaks other tests. So create a dummy one. */ - g_assert(!pipe2(pipefd, O_NONBLOCK)); + g_assert(!qemu_pipe(pipefd)); + qemu_set_nonblock(pipefd[0]); + qemu_set_nonblock(pipefd[1]); + aio_set_fd_handler(ctx, pipefd[0], dummy_io_handler_read, NULL, NULL); do {} while (g_main_context_iteration(NULL, false));