提交 4260a739 编写于 作者: P Paolo Bonzini

qemu-timer: use atexit for quit_timers

Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 a5c57d64
...@@ -840,6 +840,13 @@ static void alarm_timer_on_change_state_rearm(void *opaque, int running, ...@@ -840,6 +840,13 @@ static void alarm_timer_on_change_state_rearm(void *opaque, int running,
qemu_rearm_alarm_timer((struct qemu_alarm_timer *) opaque); qemu_rearm_alarm_timer((struct qemu_alarm_timer *) opaque);
} }
static void quit_timers(void)
{
struct qemu_alarm_timer *t = alarm_timer;
alarm_timer = NULL;
t->stop(t);
}
int init_timer_alarm(void) int init_timer_alarm(void)
{ {
struct qemu_alarm_timer *t = NULL; struct qemu_alarm_timer *t = NULL;
...@@ -859,6 +866,7 @@ int init_timer_alarm(void) ...@@ -859,6 +866,7 @@ int init_timer_alarm(void)
} }
/* first event is at time 0 */ /* first event is at time 0 */
atexit(quit_timers);
t->pending = 1; t->pending = 1;
alarm_timer = t; alarm_timer = t;
qemu_add_vm_change_state_handler(alarm_timer_on_change_state_rearm, t); qemu_add_vm_change_state_handler(alarm_timer_on_change_state_rearm, t);
...@@ -869,13 +877,6 @@ fail: ...@@ -869,13 +877,6 @@ fail:
return err; return err;
} }
void quit_timers(void)
{
struct qemu_alarm_timer *t = alarm_timer;
alarm_timer = NULL;
t->stop(t);
}
int qemu_calculate_timeout(void) int qemu_calculate_timeout(void)
{ {
return 1000; return 1000;
......
...@@ -62,7 +62,6 @@ void configure_alarms(char const *opt); ...@@ -62,7 +62,6 @@ void configure_alarms(char const *opt);
int qemu_calculate_timeout(void); int qemu_calculate_timeout(void);
void init_clocks(void); void init_clocks(void);
int init_timer_alarm(void); int init_timer_alarm(void);
void quit_timers(void);
int64_t cpu_get_ticks(void); int64_t cpu_get_ticks(void);
void cpu_enable_ticks(void); void cpu_enable_ticks(void);
......
...@@ -3565,7 +3565,6 @@ int main(int argc, char **argv, char **envp) ...@@ -3565,7 +3565,6 @@ int main(int argc, char **argv, char **envp)
os_setup_post(); os_setup_post();
main_loop(); main_loop();
quit_timers();
net_cleanup(); net_cleanup();
res_free(); res_free();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册