From patchwork Tue Aug 7 11:17:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 175609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E64862C008B for ; Tue, 7 Aug 2012 22:03:42 +1000 (EST) Received: from localhost ([::1]:37802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyhoA-0003Uu-LV for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2012 07:18:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyhnT-0001V8-In for qemu-devel@nongnu.org; Tue, 07 Aug 2012 07:18:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SyhnS-0006c4-CS for qemu-devel@nongnu.org; Tue, 07 Aug 2012 07:17:59 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:37528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyhnS-0006Zk-6N for qemu-devel@nongnu.org; Tue, 07 Aug 2012 07:17:58 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so6760377pbb.4 for ; Tue, 07 Aug 2012 04:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=RRZV2DTpZDDhHQitfQy8NYnuoSFksV1s+QM0+fI1fdc=; b=rp9bNoM4+mC8ZMbfQgr4MYUd1C+UNPv+wm9MMRWMymuU99CkSljFcyHQU9npqNHAJn 0KJd8zk2QOZ+SMgkYcSA+99t9tfgxD4P4PJPkqDzIUSh8Nuu3G+nsomx2h3NYjii4W7I OKQ+jS7CQosKJvDjR54PpY8xUnSyxi7gqUyjiqEMenzSZfKTjnaDCtSlwR3VVWix2VeZ kixaySdwfPUe9XTeEBp1pFp/W1qlVYYTcy3jq3XpLU/dG8Q+xSNeTRIxopQXPtOIrf2x cJbU4h3KuyByVcxiRQQP4z5QUNHLmQvHlGU6GkhN+3z6y8TtiJKws88Ay+44tFNYZlzX dJJg== Received: by 10.68.191.226 with SMTP id hb2mr6325619pbc.129.1344338277922; Tue, 07 Aug 2012 04:17:57 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id pq1sm11008602pbb.3.2012.08.07.04.17.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 04:17:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2012 13:17:19 +0200 Message-Id: <1344338247-17567-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344338247-17567-1-git-send-email-pbonzini@redhat.com> References: <1344338247-17567-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: aliguori@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, sw@weilnetz.de Subject: [Qemu-devel] [PATCH v2 04/12] aio: provide platform-independent API 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 This adds to aio.c a platform-independent API based on EventNotifiers, that can be used by the portable thread pool. Signed-off-by: Paolo Bonzini --- aio.c | 9 +++++++++ qemu-aio.h | 19 ++++++++++++++++++- 2 file modificati, 27 inserzioni(+). 1 rimozione(-) diff --git a/aio.c b/aio.c index 0a9eb10..417ceb4 100644 --- a/aio.c +++ b/aio.c @@ -97,6 +97,15 @@ int qemu_aio_set_fd_handler(int fd, return 0; } +void qemu_aio_set_event_notifier(EventNotifier *notifier, + EventNotifierHandler *io_read, + AioFlushEventNotifierHandler *io_flush) +{ + qemu_aio_set_fd_handler(event_notifier_get_fd(notifier), + (IOHandler *)io_read, NULL, + (AioFlushHandler *)io_flush, notifier); +} + void qemu_aio_flush(void) { while (qemu_aio_wait()); diff --git a/qemu-aio.h b/qemu-aio.h index bfdd35f..89c766c 100644 --- a/qemu-aio.h +++ b/qemu-aio.h @@ -16,6 +16,7 @@ #include "qemu-common.h" #include "qemu-char.h" +#include "event_notifier.h" typedef struct BlockDriverAIOCB BlockDriverAIOCB; typedef void BlockDriverCompletionFunc(void *opaque, int ret); @@ -39,7 +40,7 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs, void qemu_aio_release(void *p); /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */ -typedef int (AioFlushHandler)(void *opaque); +typedef int (AioFlushEventNotifierHandler)(EventNotifier *e); /* Flush any pending AIO operation. This function will block until all * outstanding AIO operations have been completed or cancelled. */ @@ -53,6 +54,10 @@ void qemu_aio_flush(void); * Return whether there is still any pending AIO operation. */ bool qemu_aio_wait(void); +#ifdef CONFIG_POSIX +/* Returns 1 if there are still outstanding AIO requests; 0 otherwise */ +typedef int (AioFlushHandler)(void *opaque); + /* Register a file descriptor and associated callbacks. Behaves very similarly * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will * be invoked when using either qemu_aio_wait() or qemu_aio_flush(). @@ -65,5 +70,17 @@ int qemu_aio_set_fd_handler(int fd, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque); +#endif + +/* Register an event notifier and associated callbacks. Behaves very similarly + * to event_notifier_set_handler. Unlike event_notifier_set_handler, these callbacks + * will be invoked when using either qemu_aio_wait() or qemu_aio_flush(). + * + * Code that invokes AIO completion functions should rely on this function + * instead of event_notifier_set_handler. + */ +void qemu_aio_set_event_notifier(EventNotifier *notifier, + EventNotifierHandler *io_read, + AioFlushEventNotifierHandler *io_flush); #endif