[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/8] system/runstate: Fix regression, clarify BQL status of exit n
From: |
David Woodhouse |
Subject: |
[PULL 8/8] system/runstate: Fix regression, clarify BQL status of exit notifiers |
Date: |
Thu, 16 Jan 2025 08:43:32 +0000 |
From: Phil Dennis-Jordan <phil@philjordan.eu>
By changing the way the main QEMU event loop is invoked, I inadvertently
changed the BQL status of exit notifiers: some of them implicitly
assumed they would be called with the BQL held; the BQL is however
not held during the exit(status) call in qemu_default_main().
Instead of attempting to ensuring we always call exit() from the BQL -
including any transitive calls - this change adds a BQL lock guard to
qemu_run_exit_notifiers, ensuring the BQL will always be held in the
exit notifiers.
Additionally, the BQL promise is now documented at the
qemu_{add,remove}_exit_notifier() declarations.
Fixes: f5ab12caba4f ("ui & main loop: Redesign of system-specific main
thread event handling")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2771
Reported-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Tested-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
include/system/system.h | 1 +
system/runstate.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/system/system.h b/include/system/system.h
index 5364ad4f27..0cbb43ec30 100644
--- a/include/system/system.h
+++ b/include/system/system.h
@@ -15,6 +15,7 @@ extern bool qemu_uuid_set;
const char *qemu_get_vm_name(void);
+/* Exit notifiers will run with BQL held. */
void qemu_add_exit_notifier(Notifier *notify);
void qemu_remove_exit_notifier(Notifier *notify);
diff --git a/system/runstate.c b/system/runstate.c
index 3a8fe866bc..272801d307 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -850,6 +850,7 @@ void qemu_remove_exit_notifier(Notifier *notify)
static void qemu_run_exit_notifiers(void)
{
+ BQL_LOCK_GUARD();
notifier_list_notify(&exit_notifiers, NULL);
}
--
2.47.0
- [PULL 0/8] Xen regression fixes and cleanups, David Woodhouse, 2025/01/16
- [PULL 5/8] hw/xen: Use xs_node_read() from xen_netdev_get_name(), David Woodhouse, 2025/01/16
- [PULL 7/8] hw/xen: Fix errp handling in xen_console, David Woodhouse, 2025/01/16
- [PULL 3/8] hw/xen: Use xs_node_read() from xs_node_vscanf(), David Woodhouse, 2025/01/16
- [PULL 8/8] system/runstate: Fix regression, clarify BQL status of exit notifiers,
David Woodhouse <=
- [PULL 6/8] hw/xen: Use xs_node_read() from xenstore_read_str() instead of open-coding it, David Woodhouse, 2025/01/16
- [PULL 4/8] hw/xen: Use xs_node_read() from xen_console_get_name(), David Woodhouse, 2025/01/16
- [PULL 2/8] xen: do not use '%ms' scanf specifier, David Woodhouse, 2025/01/16
- [PULL 1/8] hw/xen: Add xs_node_read() helper function, David Woodhouse, 2025/01/16