[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/50] main loop: macros to mark GS and I/O functions
From: |
Kevin Wolf |
Subject: |
[PULL 15/50] main loop: macros to mark GS and I/O functions |
Date: |
Fri, 4 Mar 2022 17:46:36 +0100 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Righ now, IO_CODE and IO_OR_GS_CODE are nop, as there isn't
really a way to check that a function is only called in I/O.
On the other side, we can use qemu_in_main_thread() to check if
we are in the main loop.
The usage of macros makes easy to extend them in the future without
making changes in all callers. They will also visually help understanding
in which category each function is, without looking at the header.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20220303151616.325444-3-eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/qemu/main-loop.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
index bc42b5939d..7a4d6a0920 100644
--- a/include/qemu/main-loop.h
+++ b/include/qemu/main-loop.h
@@ -269,6 +269,24 @@ bool qemu_mutex_iothread_locked(void);
*/
bool qemu_in_main_thread(void);
+/* Mark and check that the function is part of the global state API. */
+#define GLOBAL_STATE_CODE() \
+ do { \
+ assert(qemu_in_main_thread()); \
+ } while (0)
+
+/* Mark and check that the function is part of the I/O API. */
+#define IO_CODE() \
+ do { \
+ /* nop */ \
+ } while (0)
+
+/* Mark and check that the function is part of the "I/O OR GS" API. */
+#define IO_OR_GS_CODE() \
+ do { \
+ /* nop */ \
+ } while (0)
+
/**
* qemu_mutex_lock_iothread: Lock the main loop mutex.
*
--
2.35.1
- [PULL 06/50] tls: add macros for coroutine-safe TLS variables, (continued)
- [PULL 06/50] tls: add macros for coroutine-safe TLS variables, Kevin Wolf, 2022/03/04
- [PULL 08/50] rcu: use coroutine TLS macros, Kevin Wolf, 2022/03/04
- [PULL 09/50] cpus: use coroutine TLS macros for iothread_locked, Kevin Wolf, 2022/03/04
- [PULL 10/50] os-posix: Add os_set_daemonize(), Kevin Wolf, 2022/03/04
- [PULL 12/50] qsd: Add --daemonize, Kevin Wolf, 2022/03/04
- [PULL 11/50] qsd: Add pre-init argument parsing pass, Kevin Wolf, 2022/03/04
- [PULL 07/50] util/async: replace __thread with QEMU TLS macros, Kevin Wolf, 2022/03/04
- [PULL 16/50] include/block/block: split header into I/O and global state API, Kevin Wolf, 2022/03/04
- [PULL 13/50] iotests/185: Add post-READY quit tests, Kevin Wolf, 2022/03/04
- [PULL 14/50] main-loop.h: introduce qemu_in_main_thread(), Kevin Wolf, 2022/03/04
- [PULL 15/50] main loop: macros to mark GS and I/O functions,
Kevin Wolf <=
- [PULL 03/50] block: introduce bdrv_activate, Kevin Wolf, 2022/03/04
- [PULL 17/50] assertions for block global state API, Kevin Wolf, 2022/03/04
- [PULL 02/50] crypto: distinguish between main loop and I/O in block_crypto_amend_options_generic_luks, Kevin Wolf, 2022/03/04
- [PULL 19/50] block/export/fuse.c: allow writable exports to take RESIZE permission, Kevin Wolf, 2022/03/04
- [PULL 27/50] block: introduce assert_bdrv_graph_writable, Kevin Wolf, 2022/03/04
- [PULL 20/50] include/sysemu/block-backend: split header into I/O and global state (GS) API, Kevin Wolf, 2022/03/04
- [PULL 32/50] assertions for blockjob.h global state API, Kevin Wolf, 2022/03/04
- [PULL 18/50] IO_CODE and IO_OR_GS_CODE for block I/O API, Kevin Wolf, 2022/03/04
- [PULL 35/50] include/block/snapshot: global state API + assertions, Kevin Wolf, 2022/03/04
- [PULL 33/50] include/sysemu/blockdev.h: global state API, Kevin Wolf, 2022/03/04