2
0

coth.c 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * 9p backend
  3. *
  4. * Copyright IBM, Corp. 2010
  5. *
  6. * Authors:
  7. * Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
  8. * Venkateswararao Jujjuri(JV) <jvrao@linux.vnet.ibm.com>
  9. *
  10. * This work is licensed under the terms of the GNU GPL, version 2. See
  11. * the COPYING file in the top-level directory.
  12. *
  13. */
  14. /*
  15. * Not so fast! You might want to read the 9p developer docs first:
  16. * https://wiki.qemu.org/Documentation/9p
  17. */
  18. #include "qemu/osdep.h"
  19. #include "block/thread-pool.h"
  20. #include "qemu/coroutine.h"
  21. #include "qemu/main-loop.h"
  22. #include "coth.h"
  23. /* Called from QEMU I/O thread. */
  24. static void coroutine_enter_cb(void *opaque, int ret)
  25. {
  26. Coroutine *co = opaque;
  27. qemu_coroutine_enter(co);
  28. }
  29. /* Called from worker thread. */
  30. static int coroutine_enter_func(void *arg)
  31. {
  32. Coroutine *co = arg;
  33. qemu_coroutine_enter(co);
  34. return 0;
  35. }
  36. void co_run_in_worker_bh(void *opaque)
  37. {
  38. Coroutine *co = opaque;
  39. thread_pool_submit_aio(coroutine_enter_func, co, coroutine_enter_cb, co);
  40. }