From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YO4Ig-0007dj-OY for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:04:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YO4Ib-0006N7-KM for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:04:22 -0500 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:56476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YO4Ib-0006N3-EF for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:04:17 -0500 Received: by mail-wg0-f46.google.com with SMTP id a1so1023613wgh.5 for ; Wed, 18 Feb 2015 05:04:16 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54E48DCC.10108@redhat.com> Date: Wed, 18 Feb 2015 14:04:12 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150218115534.4176.12578.stgit@PASHA-ISP> <20150218115651.4176.24899.stgit@PASHA-ISP> In-Reply-To: <20150218115651.4176.24899.stgit@PASHA-ISP> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v9 12/23] timer: replace time() with QEMU_CLOCK_HOST List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgalyuk , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com On 18/02/2015 12:56, Pavel Dovgalyuk wrote: > This patch replaces time() function calls with calls to > qemu_clock_get_ns(QEMU_CLOCK_HOST). It makes such requests deterministic > in record/replay mode of icount. > > Signed-off-by: Pavel Dovgalyuk Reviewed-by: Paolo Bonzini > --- > vl.c | 12 ++++++++---- > 1 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/vl.c b/vl.c > index 8c8f142..00161f4 100644 > --- a/vl.c > +++ b/vl.c > @@ -710,13 +710,17 @@ void vm_start(void) > /***********************************************************/ > /* real time host monotonic timer */ > > +static time_t qemu_time(void) > +{ > + return qemu_clock_get_ms(QEMU_CLOCK_HOST) / 1000; > +} > + > /***********************************************************/ > /* host time/date access */ > void qemu_get_timedate(struct tm *tm, int offset) > { > - time_t ti; > + time_t ti = qemu_time(); > > - time(&ti); > ti += offset; > if (rtc_date_offset == -1) { > if (rtc_utc) > @@ -744,7 +748,7 @@ int qemu_timedate_diff(struct tm *tm) > else > seconds = mktimegm(tm) + rtc_date_offset; > > - return seconds - time(NULL); > + return seconds - qemu_time(); > } > > static void configure_rtc_date_offset(const char *startdate, int legacy) > @@ -782,7 +786,7 @@ static void configure_rtc_date_offset(const char *startdate, int legacy) > "'2006-06-17T16:01:21' or '2006-06-17'\n"); > exit(1); > } > - rtc_date_offset = time(NULL) - rtc_start_date; > + rtc_date_offset = qemu_time() - rtc_start_date; > } > } > > > >