vbox5/6: avoid negative timeouts in xhci model

Fixes #4184
This commit is contained in:
Alexander Boettcher 2021-05-31 10:12:35 +02:00 committed by Christian Helmuth
parent cf2527269f
commit 73d87073af
2 changed files with 10 additions and 2 deletions

View File

@ -154,7 +154,11 @@ struct Timer_queue : public Qemu::Timer_queue
if (TMTimerIsActive(tm_timer)) if (TMTimerIsActive(tm_timer))
TMTimerStop(tm_timer); TMTimerStop(tm_timer);
TMTimerSetNano(tm_timer, min->timeout_abs_ns - TMTimerGetNano(tm_timer)); uint64_t const now = TMTimerGetNano(tm_timer);
if (min->timeout_abs_ns < now)
TMTimerSetNano(tm_timer, 0);
else
TMTimerSetNano(tm_timer, min->timeout_abs_ns - now);
} }
void _deactivate_timer(void *qtimer) void _deactivate_timer(void *qtimer)

View File

@ -160,7 +160,11 @@ struct Timer_queue : public Qemu::Timer_queue
if (TMTimerIsActive(tm_timer)) if (TMTimerIsActive(tm_timer))
TMTimerStop(tm_timer); TMTimerStop(tm_timer);
TMTimerSetNano(tm_timer, min->timeout_abs_ns - TMTimerGetNano(tm_timer)); uint64_t const now = TMTimerGetNano(tm_timer);
if (min->timeout_abs_ns < now)
TMTimerSetNano(tm_timer, 0);
else
TMTimerSetNano(tm_timer, min->timeout_abs_ns - now);
} }
void _deactivate_timer(void *qtimer) void _deactivate_timer(void *qtimer)