summaryrefslogtreecommitdiff
path: root/qemu-timer.c
diff options
context:
space:
mode:
authorAlex Bligh <alex@alex.org.uk>2013-08-21 16:02:48 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2013-08-22 19:10:27 +0200
commit754d6a544d044bddeef87e9a63b4f511f59f3c4e (patch)
tree294e47851b21c481259cc0dcf197a4c6237ddcc6 /qemu-timer.c
parent6a1751b7aad6e38e9d1ae6bcea72fa28bf6cc5fb (diff)
downloadqemu-754d6a544d044bddeef87e9a63b4f511f59f3c4e.tar.gz
qemu-754d6a544d044bddeef87e9a63b4f511f59f3c4e.tar.bz2
qemu-754d6a544d044bddeef87e9a63b4f511f59f3c4e.zip
aio / timers: Add QEMUTimerListGroup and helper functions
Add QEMUTimerListGroup and helper functions, to represent a QEMUTimerList associated with each clock. Add a default QEMUTimerListGroup representing the default timer lists which are not associated with any other object (e.g. an AioContext as added by future patches). Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qemu-timer.c')
-rw-r--r--qemu-timer.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/qemu-timer.c b/qemu-timer.c
index b045184c04..c5e456e0b1 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -59,6 +59,7 @@ struct QEMUClock {
bool enabled;
};
+QEMUTimerListGroup main_loop_tlg;
QEMUClock *qemu_clocks[QEMU_CLOCK_MAX];
/* A QEMUTimerList is a list of timers attached to a clock. More
@@ -564,6 +565,46 @@ bool qemu_run_timers(QEMUClock *clock)
return timerlist_run_timers(clock->main_loop_timerlist);
}
+void timerlistgroup_init(QEMUTimerListGroup *tlg)
+{
+ QEMUClockType type;
+ for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+ tlg->tl[type] = timerlist_new(type);
+ }
+}
+
+void timerlistgroup_deinit(QEMUTimerListGroup *tlg)
+{
+ QEMUClockType type;
+ for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+ timerlist_free(tlg->tl[type]);
+ }
+}
+
+bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg)
+{
+ QEMUClockType type;
+ bool progress = false;
+ for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+ progress |= timerlist_run_timers(tlg->tl[type]);
+ }
+ return progress;
+}
+
+int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
+{
+ int64_t deadline = -1;
+ QEMUClockType type;
+ for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+ if (qemu_clock_use_for_deadline(tlg->tl[type]->clock)) {
+ deadline = qemu_soonest_timeout(deadline,
+ timerlist_deadline_ns(
+ tlg->tl[type]));
+ }
+ }
+ return deadline;
+}
+
int64_t qemu_get_clock_ns(QEMUClock *clock)
{
int64_t now, last;
@@ -605,6 +646,7 @@ void init_clocks(void)
for (type = 0; type < QEMU_CLOCK_MAX; type++) {
if (!qemu_clocks[type]) {
qemu_clocks[type] = qemu_clock_new(type);
+ main_loop_tlg.tl[type] = qemu_clocks[type]->main_loop_timerlist;
}
}