@@ -43,3 +43,8 @@ Coroutine * coroutine_fn qemu_coroutine_self(void)
{
return (Coroutine*)coroutine_self();
}
+
+bool qemu_in_coroutine(void)
+{
+ return !coroutine_is_leader(coroutine_self());
+}
@@ -14,6 +14,8 @@
#ifndef QEMU_COROUTINE_H
#define QEMU_COROUTINE_H
+#include <stdbool.h>
+
/**
* Mark a function that executes in coroutine context
*
@@ -78,4 +80,9 @@ void * coroutine_fn qemu_coroutine_yield(void *opaque);
*/
Coroutine * coroutine_fn qemu_coroutine_self(void);
+/**
+ * Return whether or not currently inside a coroutine
+ */
+bool qemu_in_coroutine(void);
+
#endif /* QEMU_COROUTINE_H */
The qemu_in_coroutine() function checks whether or not we are currently in a user coroutine. This can be used to distinguish between executing normal vcpu or iothread code from executing a coroutine. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> --- qemu-coroutine.c | 5 +++++ qemu-coroutine.h | 7 +++++++ 2 files changed, 12 insertions(+), 0 deletions(-)