aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2022-10-04 12:52:21 +0100
committerAlex Bennée <alex.bennee@linaro.org>2022-10-06 11:53:41 +0100
commitf7e15affa8e574a800180de3bde1a6462aec7241 (patch)
treec759a5deb49756097f301652837b14ffc91ef6b2 /include
parent37e62694e4bcc937c8c5fa6153302a5451fb12c5 (diff)
downloadqemu-f7e15affa8e574a800180de3bde1a6462aec7241.zip
qemu-f7e15affa8e574a800180de3bde1a6462aec7241.tar.gz
qemu-f7e15affa8e574a800180de3bde1a6462aec7241.tar.bz2
plugins: add [pre|post]fork helpers to linux-user
Special care needs to be taken in ensuring locks are in a consistent state across fork events. Add helpers so the plugin system can ensure that. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/358 Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Tested-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221004115221.2174499-1-alex.bennee@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/plugin.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 145f8a2..a772e14 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -224,6 +224,23 @@ void qemu_plugin_disable_mem_helpers(CPUState *cpu);
*/
void qemu_plugin_user_exit(void);
+/**
+ * qemu_plugin_user_prefork_lock(): take plugin lock before forking
+ *
+ * This is a user-mode only helper to take the internal plugin lock
+ * before a fork event. This is ensure a consistent lock state
+ */
+void qemu_plugin_user_prefork_lock(void);
+
+/**
+ * qemu_plugin_user_postfork(): reset the plugin lock
+ * @is_child: is this thread the child
+ *
+ * This user-mode only helper resets the lock state after a fork so we
+ * can continue using the plugin interface.
+ */
+void qemu_plugin_user_postfork(bool is_child);
+
#else /* !CONFIG_PLUGIN */
static inline void qemu_plugin_add_opts(void)
@@ -287,6 +304,13 @@ static inline void qemu_plugin_disable_mem_helpers(CPUState *cpu)
static inline void qemu_plugin_user_exit(void)
{ }
+
+static inline void qemu_plugin_user_prefork_lock(void)
+{ }
+
+static inline void qemu_plugin_user_postfork(bool is_child)
+{ }
+
#endif /* !CONFIG_PLUGIN */
#endif /* QEMU_PLUGIN_H */