diff options
author | Daniel Henrique Barboza <danielhb413@gmail.com> | 2021-03-01 09:41:33 -0300 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-03-10 09:07:09 +1100 |
commit | 4515a5f786024fabf0bef4cf3d28adf5647e6e82 (patch) | |
tree | 6499b4ee6bc825ac039be968ecf08a9d169d0170 /util | |
parent | e35dfbd22780aafbcd4b6da5130a00fc085fd5de (diff) |
qemu_timer.c: add timer_deadline_ms() helper
The pSeries machine is using QEMUTimer internals to return the timeout
in seconds for a timer object, in hw/ppc/spapr.c, function
spapr_drc_unplug_timeout_remaining_sec().
Create a helper in qemu-timer.c to retrieve the deadline for a QEMUTimer
object, in ms, to avoid exposing timer internals to the PPC code.
CC: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210301124133.23800-2-danielhb413@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-timer.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 81c28af517..02424bc1b6 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -243,6 +243,19 @@ int64_t timerlist_deadline_ns(QEMUTimerList *timer_list) return delta; } +/* + * Returns the time remaining for the deadline, in ms. + */ +int64_t timer_deadline_ms(QEMUTimer *timer) +{ + if (timer_pending(timer)) { + return qemu_timeout_ns_to_ms(timer->expire_time) - + qemu_clock_get_ms(timer->timer_list->clock->type); + } + + return 0; +} + /* Calculate the soonest deadline across all timerlists attached * to the clock. This is used for the icount timeout so we * ignore whether or not the clock should be used in deadline |