qemu-aio.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef QEMU_AIO_H
  14. #define QEMU_AIO_H
  15. #include "qemu-common.h"
  16. #include "qemu-char.h"
  17. /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */
  18. typedef int (AioFlushHandler)(void *opaque);
  19. /* Flush any pending AIO operation. This function will block until all
  20. * outstanding AIO operations have been completed or cancelled. */
  21. void qemu_aio_flush(void);
  22. /* Wait for a single AIO completion to occur. This function will wait
  23. * until a single AIO event has completed and it will ensure something
  24. * has moved before returning. This can issue new pending aio as
  25. * result of executing I/O completion or bh callbacks. */
  26. void qemu_aio_wait(void);
  27. /* Register a file descriptor and associated callbacks. Behaves very similarly
  28. * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will
  29. * be invoked when using either qemu_aio_wait() or qemu_aio_flush().
  30. *
  31. * Code that invokes AIO completion functions should rely on this function
  32. * instead of qemu_set_fd_handler[2].
  33. */
  34. int qemu_aio_set_fd_handler(int fd,
  35. IOHandler *io_read,
  36. IOHandler *io_write,
  37. AioFlushHandler *io_flush,
  38. void *opaque);
  39. #endif