[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/17] vl.c: remove init_clocks call from main
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 11/17] vl.c: remove init_clocks call from main |
Date: |
Fri, 9 May 2014 21:03:31 +0200 |
From: Kirill Batuzov <address@hidden>
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 <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qemu-timer.c | 3 +++
vl.c | 1 -
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/qemu-timer.c b/qemu-timer.c
index 9be1a41..00a5d35 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -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 73e0661..709d8cd 100644
--- 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);
--
1.9.0
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, (continued)
[Qemu-devel] [PULL 04/17] block/nfs: Check for NULL server part, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 06/17] qemu-img: Convert by cluster size if target is compressed, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 05/17] block/iscsi: bump year in copyright notice, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 07/17] vmdk: Implement .bdrv_write_compressed, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 08/17] vmdk: Implement .bdrv_get_info(), Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 09/17] qemu-iotests: Test converting to streamOptimized from small cluster size, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 10/17] block: Fix open flags with BDRV_O_SNAPSHOT, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 11/17] vl.c: remove init_clocks call from main,
Stefan Hajnoczi <=
[Qemu-devel] [PULL 12/17] gluster: Correctly propagate errors when volume isn't accessible, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 13/17] block/raw-posix: Try both FIEMAP and SEEK_HOLE, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 14/17] block: qemu-iotests - add common.qemu, for bash-controlled qemu tests, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 15/17] block: qemu-iotests - update 085 to use common.qemu, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 16/17] block: qemu-iotests - test for live migration, Stefan Hajnoczi, 2014/05/09
[Qemu-devel] [PULL 17/17] glib: fix g_poll early timeout on windows, Stefan Hajnoczi, 2014/05/09
Re: [Qemu-devel] [PULL 00/17] Block patches, Peter Maydell, 2014/05/13