qemu-aio.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /* Runs all currently allowed AIO callbacks of completed requests in the
  20. * respective AIO backend. Returns 0 if no requests was handled, non-zero
  21. * if at least one queued request was handled. */
  22. typedef int (AioProcessQueue)(void *opaque);
  23. /* Flush any pending AIO operation. This function will block until all
  24. * outstanding AIO operations have been completed or cancelled. */
  25. void qemu_aio_flush(void);
  26. /* Wait for a single AIO completion to occur. This function will wait
  27. * until a single AIO event has completed and it will ensure something
  28. * has moved before returning. This can issue new pending aio as
  29. * result of executing I/O completion or bh callbacks. */
  30. void qemu_aio_wait(void);
  31. /*
  32. * Runs all currently allowed AIO callbacks of completed requests. Returns 0
  33. * if no requests were handled, non-zero if at least one request was
  34. * processed.
  35. */
  36. int qemu_aio_process_queue(void);
  37. /* Register a file descriptor and associated callbacks. Behaves very similarly
  38. * to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will
  39. * be invoked when using either qemu_aio_wait() or qemu_aio_flush().
  40. *
  41. * Code that invokes AIO completion functions should rely on this function
  42. * instead of qemu_set_fd_handler[2].
  43. */
  44. int qemu_aio_set_fd_handler(int fd,
  45. IOHandler *io_read,
  46. IOHandler *io_write,
  47. AioFlushHandler *io_flush,
  48. AioProcessQueue *io_process_queue,
  49. void *opaque);
  50. #endif