aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/ppc/spapr_drc.c5
-rw-r--r--include/qemu/timer.h8
-rw-r--r--util/qemu-timer.c13
3 files changed, 23 insertions, 3 deletions
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 8c4997d795..98b626acf9 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -421,9 +421,8 @@ void spapr_drc_unplug_request(SpaprDrc *drc)
int spapr_drc_unplug_timeout_remaining_sec(SpaprDrc *drc)
{
- if (drc->unplug_requested && timer_pending(drc->unplug_timeout_timer)) {
- return (qemu_timeout_ns_to_ms(drc->unplug_timeout_timer->expire_time) -
- qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)) / 1000;
+ if (drc->unplug_requested) {
+ return timer_deadline_ms(drc->unplug_timeout_timer) / 1000;
}
return 0;
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 1678238384..5e76e3f8c2 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -795,6 +795,14 @@ static inline int64_t get_max_clock_jump(void)
return 60 * NANOSECONDS_PER_SECOND;
}
+/**
+ * timer_deadline_ms:
+ *
+ * Returns the remaining miliseconds for @timer to expire, or zero
+ * if the timer is no longer pending.
+ */
+int64_t timer_deadline_ms(QEMUTimer *timer);
+
/*
* Low level clock functions
*/
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