|
@@ -242,9 +242,33 @@ AioContext *iohandler_get_aio_context(void);
|
|
* must always be taken outside other locks. This function helps
|
|
* must always be taken outside other locks. This function helps
|
|
* functions take different paths depending on whether the current
|
|
* functions take different paths depending on whether the current
|
|
* thread is running within the main loop mutex.
|
|
* thread is running within the main loop mutex.
|
|
|
|
+ *
|
|
|
|
+ * This function should never be used in the block layer, because
|
|
|
|
+ * unit tests, block layer tools and qemu-storage-daemon do not
|
|
|
|
+ * have a BQL.
|
|
|
|
+ * Please instead refer to qemu_in_main_thread().
|
|
*/
|
|
*/
|
|
bool qemu_mutex_iothread_locked(void);
|
|
bool qemu_mutex_iothread_locked(void);
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * qemu_in_main_thread: return whether it's possible to safely access
|
|
|
|
+ * the global state of the block layer.
|
|
|
|
+ *
|
|
|
|
+ * Global state of the block layer is not accessible from I/O threads
|
|
|
|
+ * or worker threads; only from threads that "own" the default
|
|
|
|
+ * AioContext that qemu_get_aio_context() returns. For tests, block
|
|
|
|
+ * layer tools and qemu-storage-daemon there is a designated thread that
|
|
|
|
+ * runs the event loop for qemu_get_aio_context(), and that is the
|
|
|
|
+ * main thread.
|
|
|
|
+ *
|
|
|
|
+ * For emulators, however, any thread that holds the BQL can act
|
|
|
|
+ * as the block layer main thread; this will be any of the actual
|
|
|
|
+ * main thread, the vCPU threads or the RCU thread.
|
|
|
|
+ *
|
|
|
|
+ * For clarity, do not use this function outside the block layer.
|
|
|
|
+ */
|
|
|
|
+bool qemu_in_main_thread(void);
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* qemu_mutex_lock_iothread: Lock the main loop mutex.
|
|
* qemu_mutex_lock_iothread: Lock the main loop mutex.
|
|
*
|
|
*
|