qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] plugins: Avoid deadlock in qemu_plugin_user_exit


From: Richard Henderson
Subject: [PATCH 2/3] plugins: Avoid deadlock in qemu_plugin_user_exit
Date: Mon, 16 Jan 2023 17:57:00 -1000

Use of start_exclusive on this exit path leads to deadlock,
in particular when called from dump_core_and_abort.  There
does not appear to be a need for it.

While we're at it, skip the entire function if no plugins.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 plugins/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/core.c b/plugins/core.c
index ccb770a485..35aca0266d 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -502,7 +502,9 @@ void qemu_plugin_user_exit(void)
 
     QEMU_LOCK_GUARD(&plugin.lock);
 
-    start_exclusive();
+    if (QTAILQ_EMPTY(&plugin.ctxs)) {
+        return;
+    }
 
     /* un-register all callbacks except the final AT_EXIT one */
     for (ev = 0; ev < QEMU_PLUGIN_EV_MAX; ev++) {
@@ -520,8 +522,6 @@ void qemu_plugin_user_exit(void)
         qemu_plugin_disable_mem_helpers(cpu);
     }
 
-    end_exclusive();
-
     /* now it's safe to handle the exit case */
     qemu_plugin_atexit_cb();
 }
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]