]> Git Repo - qemu.git/commitdiff
vl.c: remove init_clocks call from main
authorKirill Batuzov <[email protected]>
Tue, 6 May 2014 12:59:53 +0000 (16:59 +0400)
committerStefan Hajnoczi <[email protected]>
Fri, 9 May 2014 18:57:32 +0000 (20:57 +0200)
Clocks are initialized in qemu_init_main_loop. They are not needed before it.
Initializing them twice is not only unnecessary but is harmful: it results in
memory leak and potentially can lead to a situation where different parts of
QEMU use different sets of timers.

To avoid it remove init_clocks call from main and add an assertion to
qemu_clock_init that corresponding clock has not been initialized yet.

Signed-off-by: Kirill Batuzov <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
qemu-timer.c
vl.c

index 9be1a4131d6318f7b6d3f93e3b1253f5884d82eb..00a5d35c3f64f5c9a65a5ade0e85273e3555e5c0 100644 (file)
@@ -126,6 +126,9 @@ static void qemu_clock_init(QEMUClockType type)
 {
     QEMUClock *clock = qemu_clock_ptr(type);
 
+    /* Assert that the clock of type TYPE has not been initialized yet. */
+    assert(main_loop_tlg.tl[type] == NULL);
+
     clock->type = type;
     clock->enabled = true;
     clock->last = INT64_MIN;
diff --git a/vl.c b/vl.c
index 73e06610b057b3e0c90258c251ec2ab1f0130556..709d8cda8dc63715cc7f760e1fb142ae65f7fd5c 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3024,7 +3024,6 @@ int main(int argc, char **argv, char **envp)
 
     runstate_init();
 
-    init_clocks();
     rtc_clock = QEMU_CLOCK_HOST;
 
     qemu_init_auxval(envp);
This page took 0.035863 seconds and 4 git commands to generate.