Skip to content

Commit e7bc020

Browse files
pmjdwmw2
authored andcommitted
system/runstate: Fix regression, clarify BQL status of exit notifiers
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: f5ab12c ("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>
1 parent 8b44a3e commit e7bc020

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

include/system/system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern bool qemu_uuid_set;
1515

1616
const char *qemu_get_vm_name(void);
1717

18+
/* Exit notifiers will run with BQL held. */
1819
void qemu_add_exit_notifier(Notifier *notify);
1920
void qemu_remove_exit_notifier(Notifier *notify);
2021

system/runstate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ void qemu_remove_exit_notifier(Notifier *notify)
850850

851851
static void qemu_run_exit_notifiers(void)
852852
{
853+
BQL_LOCK_GUARD();
853854
notifier_list_notify(&exit_notifiers, NULL);
854855
}
855856

0 commit comments

Comments
 (0)