Patchwork [v3,07/13] qemu-timer: use atexit for quit_timers

login
register
mail settings
Submitter Paolo Bonzini
Date Oct. 21, 2011, 4:26 p.m.
Message ID <1319214405-20388-8-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/121034/
State New
Headers show

Comments

Paolo Bonzini - Oct. 21, 2011, 4:26 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-timer.c |   15 ++++++++-------
 qemu-timer.h |    1 -
 vl.c         |    1 -
 3 files changed, 8 insertions(+), 9 deletions(-)

Patch

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 @@  static void alarm_timer_on_change_state_rearm(void *opaque, int running,
         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 @@  int init_timer_alarm(void)
     }
 
     /* 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 @@  fail:
     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 @@  void configure_alarms(char const *opt);
 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 @@  int main(int argc, char **argv, char **envp)
     os_setup_post();
 
     main_loop();
-    quit_timers();
     net_cleanup();
     res_free();