]> git.proxmox.com Git - qemu.git/blame - qemu-aio.h
rtl8139: do not assume TxStatus[] and TxAddr[] are adjacent
[qemu.git] / qemu-aio.h
CommitLineData
a76bab49
AL
1/*
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
85e8dab1
PB
20typedef struct BlockDriverAIOCB BlockDriverAIOCB;
21typedef void BlockDriverCompletionFunc(void *opaque, int ret);
22
23typedef struct AIOPool {
24 void (*cancel)(BlockDriverAIOCB *acb);
25 int aiocb_size;
26 BlockDriverAIOCB *free_aiocb;
27} AIOPool;
28
29struct BlockDriverAIOCB {
30 AIOPool *pool;
31 BlockDriverState *bs;
32 BlockDriverCompletionFunc *cb;
33 void *opaque;
34 BlockDriverAIOCB *next;
35};
36
37void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
38 BlockDriverCompletionFunc *cb, void *opaque);
39void qemu_aio_release(void *p);
40
a76bab49
AL
41/* Returns 1 if there are still outstanding AIO requests; 0 otherwise */
42typedef int (AioFlushHandler)(void *opaque);
43
8febfa26
KW
44/* Runs all currently allowed AIO callbacks of completed requests in the
45 * respective AIO backend. Returns 0 if no requests was handled, non-zero
46 * if at least one queued request was handled. */
47typedef int (AioProcessQueue)(void *opaque);
48
a76bab49
AL
49/* Flush any pending AIO operation. This function will block until all
50 * outstanding AIO operations have been completed or cancelled. */
51void qemu_aio_flush(void);
52
986c28d6
AA
53/* Wait for a single AIO completion to occur. This function will wait
54 * until a single AIO event has completed and it will ensure something
55 * has moved before returning. This can issue new pending aio as
56 * result of executing I/O completion or bh callbacks. */
a76bab49
AL
57void qemu_aio_wait(void);
58
8febfa26
KW
59/*
60 * Runs all currently allowed AIO callbacks of completed requests. Returns 0
61 * if no requests were handled, non-zero if at least one request was
62 * processed.
63 */
64int qemu_aio_process_queue(void);
65
a76bab49
AL
66/* Register a file descriptor and associated callbacks. Behaves very similarly
67 * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will
68 * be invoked when using either qemu_aio_wait() or qemu_aio_flush().
69 *
70 * Code that invokes AIO completion functions should rely on this function
71 * instead of qemu_set_fd_handler[2].
72 */
73int qemu_aio_set_fd_handler(int fd,
74 IOHandler *io_read,
75 IOHandler *io_write,
76 AioFlushHandler *io_flush,
8febfa26 77 AioProcessQueue *io_process_queue,
a76bab49
AL
78 void *opaque);
79
80#endif