aboutsummaryrefslogtreecommitdiff
path: root/plugins
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 /plugins
parent37e62694e4bcc937c8c5fa6153302a5451fb12c5 (diff)
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 'plugins')
-rw-r--r--plugins/core.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/core.c b/plugins/core.c
index c3ae284994..ccb770a485 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -527,6 +527,26 @@ void qemu_plugin_user_exit(void)
}
/*
+ * Helpers for *-user to ensure locks are sane across fork() events.
+ */
+
+void qemu_plugin_user_prefork_lock(void)
+{
+ qemu_rec_mutex_lock(&plugin.lock);
+}
+
+void qemu_plugin_user_postfork(bool is_child)
+{
+ if (is_child) {
+ /* should we just reset via plugin_init? */
+ qemu_rec_mutex_init(&plugin.lock);
+ } else {
+ qemu_rec_mutex_unlock(&plugin.lock);
+ }
+}
+
+
+/*
* Call this function after longjmp'ing to the main loop. It's possible that the
* last instruction of a TB might have used helpers, and therefore the
* "disable" instruction will never execute because it ended up as dead code.