X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/84942979de3b7204ff53dbd263f8919897c779b2..548ebcaf361443420a9f3ab0e2118c4d1f0a1b72:/qemu-timer.c diff --git a/qemu-timer.c b/qemu-timer.c index f16e422837..9299cdc5fb 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu/main-loop.h" #include "qemu/timer.h" #include "sysemu/replay.h" @@ -128,7 +129,7 @@ static void qemu_clock_init(QEMUClockType type) assert(main_loop_tlg.tl[type] == NULL); clock->type = type; - clock->enabled = true; + clock->enabled = (type == QEMU_CLOCK_VIRTUAL ? false : true); clock->last = INT64_MIN; QLIST_INIT(&clock->timerlists); notifier_list_init(&clock->reset_notifiers); @@ -291,7 +292,7 @@ int qemu_timeout_ns_to_ms(int64_t ns) /* Always round up, because it's better to wait too long than to wait too * little and effectively busy-wait */ - ms = (ns + SCALE_MS - 1) / SCALE_MS; + ms = DIV_ROUND_UP(ns, SCALE_MS); /* To avoid overflow problems, limit this to 2^31, i.e. approx 25 days */ if (ms > (int64_t) INT32_MAX) { @@ -393,7 +394,9 @@ static bool timer_mod_ns_locked(QEMUTimerList *timer_list, static void timerlist_rearm(QEMUTimerList *timer_list) { /* Interrupt execution to force deadline recalculation. */ - qemu_clock_warp(timer_list->clock->type); + if (timer_list->clock->type == QEMU_CLOCK_VIRTUAL) { + qemu_start_warp_timer(); + } timerlist_notify(timer_list); }