summaryrefslogtreecommitdiff
path: root/qemu-timer.c
diff options
context:
space:
mode:
authorPaul Donohue <qemu-devel@PaulSD.com>2015-06-12 10:08:45 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-06-19 12:27:14 +0200
commitfb1a3a051d89975f26296163066bb0745ecca49d (patch)
tree36813c9e3e43c4252387f79cf5002f15e4a83f93 /qemu-timer.c
parent397c767b2de5b918a7b890d02aae83d6dcb2a470 (diff)
downloadqemu-fb1a3a051d89975f26296163066bb0745ecca49d.tar.gz
qemu-fb1a3a051d89975f26296163066bb0745ecca49d.tar.bz2
qemu-fb1a3a051d89975f26296163066bb0745ecca49d.zip
qemu-timer: Call clock reset notifiers on forward jumps
Commit 691a0c9c introduced a mechanism by which QEMU_CLOCK_HOST can notify other parts of the emulator when the host clock has jumped backward. This is used to avoid stalling timers that were scheduled based on the host clock. However, if the host clock jumps forward, then timers that were scheduled based on the host clock may fire rapidly and cause other problems. For example, the mc146818rtc periodic timer will block execution of the VM and consume host CPU while firing every interrupt for the time period that was skipped by the host clock. To correct that problem, this commit fires the reset notification if the host clock jumps forward by more than a hard-coded limit. The limit is currently set to a value of 60 seconds, which should be small enough to prevent excessive timer loops, but large enough to avoid frequent resets in idle VMs. Signed-off-by: Paul Donohue <qemu-git@PaulSD.com> Message-Id: <20150612140845.GD2749@TopQuark.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-timer.c')
-rw-r--r--qemu-timer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/qemu-timer.c b/qemu-timer.c
index 5741f0d0e0..aa6757e359 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -573,7 +573,7 @@ int64_t qemu_clock_get_ns(QEMUClockType type)
now = get_clock_realtime();
last = clock->last;
clock->last = now;
- if (now < last) {
+ if (now < last || now > (last + get_max_clock_jump())) {
notifier_list_notify(&clock->reset_notifiers, &now);
}
return now;