Received: from eggs.gnu.org ([2001:4830:134:3::10]:52945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whxdx-0001Hj-2E for qemu-devel@nongnu.org; Wed, 07 May 2014 04:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Whxds-0006se-3I for qemu-devel@nongnu.org; Wed, 07 May 2014 04:56:01 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:48288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whxdr-0006sX-TL for qemu-devel@nongnu.org; Wed, 07 May 2014 04:55:56 -0400 Received: by mail-we0-f179.google.com with SMTP id q59so648921wes.24 for ; Wed, 07 May 2014 01:55:55 -0700 (PDT) Date: Wed, 7 May 2014 10:45:53 +0200 From: Stefan Hajnoczi Message-ID: <20140507084553.GF27925@stefanha-thinkpad.muc.redhat.com> References: <1399381193-2662-1-git-send-email-batuzovk@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1399381193-2662-1-git-send-email-batuzovk@ispras.ru> Subject: Re: [Qemu-devel] [PATCH] vl.c: remove init_clocks call from main List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Batuzov Cc: Alex Bligh , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi , Anthony Liguori On Tue, May 06, 2014 at 04:59:53PM +0400, 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 > --- > 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. Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan