diff options
author | Alex Bligh <alex@alex.org.uk> | 2013-08-21 16:02:45 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-08-22 19:10:27 +0200 |
commit | f9a976b7408f061fc7fc48b14d16797ed6f8fd97 (patch) | |
tree | dc49cb5457a7e41e33efe59314ae570df27bccd1 /qemu-timer.c | |
parent | cd758dd0acaaf1f76f9727d4409915f3293db07a (diff) | |
download | hqemu-f9a976b7408f061fc7fc48b14d16797ed6f8fd97.zip hqemu-f9a976b7408f061fc7fc48b14d16797ed6f8fd97.tar.gz |
aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress
Make qemu_run_timers and qemu_run_all_timers return progress
so that aio_poll etc. can determine whether a timer has been
run.
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.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/qemu-timer.c b/qemu-timer.c index 74f904b..52a1947 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -446,13 +446,14 @@ bool timer_expired(QEMUTimer *timer_head, int64_t current_time) return timer_expired_ns(timer_head, current_time * timer_head->scale); } -void qemu_run_timers(QEMUClock *clock) +bool qemu_run_timers(QEMUClock *clock) { QEMUTimer *ts; int64_t current_time; + bool progress = false; if (!clock->enabled) - return; + return progress; current_time = qemu_get_clock_ns(clock); for(;;) { @@ -466,7 +467,9 @@ void qemu_run_timers(QEMUClock *clock) /* run the callback (the timer list can be modified) */ ts->cb(ts->opaque); + progress = true; } + return progress; } int64_t qemu_get_clock_ns(QEMUClock *clock) @@ -521,20 +524,23 @@ uint64_t timer_expire_time_ns(QEMUTimer *ts) return timer_pending(ts) ? ts->expire_time : -1; } -void qemu_run_all_timers(void) +bool qemu_run_all_timers(void) { + bool progress = false; alarm_timer->pending = false; /* vm time timers */ - qemu_run_timers(vm_clock); - qemu_run_timers(rt_clock); - qemu_run_timers(host_clock); + progress |= qemu_run_timers(vm_clock); + progress |= qemu_run_timers(rt_clock); + progress |= qemu_run_timers(host_clock); /* rearm timer, if not periodic */ if (alarm_timer->expired) { alarm_timer->expired = false; qemu_rearm_alarm_timer(alarm_timer); } + + return progress; } #ifdef _WIN32 |