check for bs->drv in bdrv_flush (Christoph Hellwig)
[qemu] / posix-aio-compat.h
1 /*
2  * QEMU posix-aio emulation
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_POSIX_AIO_COMPAT_H
15 #define QEMU_POSIX_AIO_COMPAT_H
16
17 #include <sys/types.h>
18 #include <unistd.h>
19 #include <signal.h>
20
21 #include "sys-queue.h"
22
23 #define QEMU_PAIO_CANCELED     0x01
24 #define QEMU_PAIO_NOTCANCELED  0x02
25 #define QEMU_PAIO_ALLDONE      0x03
26
27 struct qemu_paiocb
28 {
29     int aio_fildes;
30     void *aio_buf;
31     size_t aio_nbytes;
32 #define aio_ioctl_cmd   aio_nbytes /* for QEMU_PAIO_IOCTL */
33     int ev_signo;
34     off_t aio_offset;
35
36     /* private */
37     TAILQ_ENTRY(qemu_paiocb) node;
38     int aio_type;
39 #define QEMU_PAIO_READ         0x01
40 #define QEMU_PAIO_WRITE        0x02
41 #define QEMU_PAIO_IOCTL        0x03
42     ssize_t ret;
43     int active;
44 };
45
46 struct qemu_paioinit
47 {
48     unsigned int aio_threads;
49     unsigned int aio_num;
50     unsigned int aio_idle_time;
51 };
52
53 int qemu_paio_init(struct qemu_paioinit *aioinit);
54 int qemu_paio_read(struct qemu_paiocb *aiocb);
55 int qemu_paio_write(struct qemu_paiocb *aiocb);
56 int qemu_paio_ioctl(struct qemu_paiocb *aiocb);
57 int qemu_paio_error(struct qemu_paiocb *aiocb);
58 ssize_t qemu_paio_return(struct qemu_paiocb *aiocb);
59 int qemu_paio_cancel(int fd, struct qemu_paiocb *aiocb);
60
61 #endif