qemu-timer: use atexit for quit_timers
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/qemu-timer.c b/qemu-timer.c
index d8507e3..7fa81e1 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -840,6 +840,13 @@
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)
{
struct qemu_alarm_timer *t = NULL;
@@ -859,6 +866,7 @@
}
/* first event is at time 0 */
+ atexit(quit_timers);
t->pending = 1;
alarm_timer = t;
qemu_add_vm_change_state_handler(alarm_timer_on_change_state_rearm, t);
@@ -869,13 +877,6 @@
return err;
}
-void quit_timers(void)
-{
- struct qemu_alarm_timer *t = alarm_timer;
- alarm_timer = NULL;
- t->stop(t);
-}
-
int qemu_calculate_timeout(void)
{
return 1000;
diff --git a/qemu-timer.h b/qemu-timer.h
index ce576b9..b4ea201 100644
--- a/qemu-timer.h
+++ b/qemu-timer.h
@@ -62,7 +62,6 @@
int qemu_calculate_timeout(void);
void init_clocks(void);
int init_timer_alarm(void);
-void quit_timers(void);
int64_t cpu_get_ticks(void);
void cpu_enable_ticks(void);
diff --git a/vl.c b/vl.c
index 66f70fb..6bd7e71 100644
--- a/vl.c
+++ b/vl.c
@@ -3565,7 +3565,6 @@
os_setup_post();
main_loop();
- quit_timers();
net_cleanup();
res_free();