提交 02ce232c 编写于 作者: K Kirill Batuzov 提交者: Stefan Hajnoczi

vl.c: remove init_clocks call from main

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: NKirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 b1e6fc08
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册