qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] vl.c: remove init_clocks call from main


From: Alex Bligh
Subject: Re: [Qemu-devel] [PATCH] vl.c: remove init_clocks call from main
Date: Tue, 6 May 2014 16:57:00 +0100

On 6 May 2014, at 13:59, Kirill Batuzov wrote:

> 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>
> ---
> qemu-timer.c |    3 +++
> vl.c         |    1 -
> 2 files changed, 3 insertions(+), 1 deletion(-)
> 
> The init_clocks call was added to qemu_init_main_loop in commit
> 172061a0a0d98c974ea8d5ed715195237bc44225. init_clocks was made idempotent
> in prior commit 744ca8e3754e6808c6b5331d287adc533fca0ad3. Back then it was
> not possible to remove init_clocks call from main because rtc_clock variable
> was of type QEMUClock * and was used in option processing. So clocks needed to
> be initialized before command line options could be processed.
> 
> Commit 7bf8fbde449600926370f744b2b3d9cc819ca74f removed idempotence property
> from init_clocks. Commit 884f17c235095af99b92dd8cd10bb824a5b0f777 removed
> the need to call init_clocks from main, but did not remove the call.

So if I read this right, init_clocks() is now only done in vl.c.

I think this is problematic, as qemu-img (for instance) still uses the
mainloop (it calls qemu_init_main_loop() from main), but does not use
vl.c as far as I know.

Perhaps restoring the idempotence would be a better plan.

-- 
Alex Bligh







reply via email to

[Prev in Thread] Current Thread [Next in Thread]