blob: 3bdd749f8054cba89e6d989cbaba96b9f7327e44 [file] [log] [blame]
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -07001/*
2 * QEMU aio implementation
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef QEMU_AIO_H
15#define QEMU_AIO_H
16
17#include "qemu-common.h"
18#include "qemu-char.h"
19
20/* Returns 1 if there are still outstanding AIO requests; 0 otherwise */
21typedef int (AioFlushHandler)(void *opaque);
22
David 'Digit' Turner2910f182010-05-10 18:48:35 -070023/* Runs all currently allowed AIO callbacks of completed requests in the
24 * respective AIO backend. Returns 0 if no requests was handled, non-zero
25 * if at least one queued request was handled. */
26typedef int (AioProcessQueue)(void *opaque);
27
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070028/* Flush any pending AIO operation. This function will block until all
29 * outstanding AIO operations have been completed or cancelled. */
30void qemu_aio_flush(void);
31
32/* Wait for a single AIO completion to occur. This function will wait
33 * until a single AIO event has completed and it will ensure something
34 * has moved before returning. This can issue new pending aio as
35 * result of executing I/O completion or bh callbacks. */
36void qemu_aio_wait(void);
37
David Turner7627ed72010-09-10 00:21:05 +020038/*
39 * Runs all currently allowed AIO callbacks of completed requests. Returns 0
40 * if no requests were handled, non-zero if at least one request was
41 * processed.
42 */
43int qemu_aio_process_queue(void);
44
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070045/* Register a file descriptor and associated callbacks. Behaves very similarly
46 * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will
47 * be invoked when using either qemu_aio_wait() or qemu_aio_flush().
48 *
49 * Code that invokes AIO completion functions should rely on this function
50 * instead of qemu_set_fd_handler[2].
51 */
52int qemu_aio_set_fd_handler(int fd,
53 IOHandler *io_read,
54 IOHandler *io_write,
55 AioFlushHandler *io_flush,
David Turner7627ed72010-09-10 00:21:05 +020056 AioProcessQueue *io_process_queue,
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070057 void *opaque);
58
59#endif