00001 /* 00002 * QEMU aio implementation 00003 * 00004 * Copyright IBM, Corp. 2008 00005 * 00006 * Authors: 00007 * Anthony Liguori <aliguori@us.ibm.com> 00008 * 00009 * This work is licensed under the terms of the GNU GPL, version 2. See 00010 * the COPYING file in the top-level directory. 00011 * 00012 */ 00013 00014 #ifndef QEMU_AIO_H 00015 #define QEMU_AIO_H 00016 00017 #include "qemu-common.h" 00018 #include "qemu-char.h" 00019 00020 /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */ 00021 typedef int (AioFlushHandler)(void *opaque); 00022 00023 /* Flush any pending AIO operation. This function will block until all 00024 * outstanding AIO operations have been completed or cancelled. */ 00025 void qemu_aio_flush(void); 00026 00027 /* Wait for a single AIO completion to occur. This function will until a 00028 * single AIO opeartion has completed. It is intended to be used as a looping 00029 * primative when simulating synchronous IO based on asynchronous IO. */ 00030 void qemu_aio_wait(void); 00031 00032 /* Register a file descriptor and associated callbacks. Behaves very similarly 00033 * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will 00034 * be invoked when using either qemu_aio_wait() or qemu_aio_flush(). 00035 * 00036 * Code that invokes AIO completion functions should rely on this function 00037 * instead of qemu_set_fd_handler[2]. 00038 */ 00039 int qemu_aio_set_fd_handler(int fd, 00040 IOHandler *io_read, 00041 IOHandler *io_write, 00042 AioFlushHandler *io_flush, 00043 void *opaque); 00044 00045 #endif