diff options
author | Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> | 2015-02-27 16:11:02 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-02-27 15:15:50 +0100 |
commit | 2ed1ebcf65edf6757d8904000889ce52cc0a9d1b (patch) | |
tree | ac8d02f7527e36d4a295f2d56e57b1093387382e /vl.c | |
parent | 0543055967e554b5be10c3f96c077bf26dcaf181 (diff) |
timer: replace time() with QEMU_CLOCK_HOST
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.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Message-Id: <20150227131102.11912.89850.stgit@PASHA-ISP>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; } } |