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