Commit c8122c35 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Anthony Liguori

qemu-timer: reinitialize timers after fork

Timers are not inherited by the child of a fork(2), so just use
pthread_atfork to reinstate them after daemonize.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent c166cb72
......@@ -742,6 +742,17 @@ static void quit_timers(void)
t->stop(t);
}
static void reinit_timers(void)
{
struct qemu_alarm_timer *t = alarm_timer;
t->stop(t);
if (t->start(t)) {
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
qemu_rearm_alarm_timer(t);
}
int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
......@@ -765,6 +776,9 @@ int init_timer_alarm(void)
}
atexit(quit_timers);
#ifdef CONFIG_POSIX
pthread_atfork(NULL, NULL, reinit_timers);
#endif
alarm_timer = t;
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment