qemu-timer.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  2. * QEMU System Emulator
  3. *
  4. * Copyright (c) 2003-2008 Fabrice Bellard
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #include "qemu/osdep.h"
  25. #include "qemu/main-loop.h"
  26. #include "qemu/timer.h"
  27. #include "sysemu/replay.h"
  28. #include "sysemu/sysemu.h"
  29. #include "sysemu/cpus.h"
  30. #ifdef CONFIG_POSIX
  31. #include <pthread.h>
  32. #endif
  33. #ifdef CONFIG_PPOLL
  34. #include <poll.h>
  35. #endif
  36. #ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK
  37. #include <sys/prctl.h>
  38. #endif
  39. /***********************************************************/
  40. /* timers */
  41. typedef struct QEMUClock {
  42. /* We rely on BQL to protect the timerlists */
  43. QLIST_HEAD(, QEMUTimerList) timerlists;
  44. NotifierList reset_notifiers;
  45. int64_t last;
  46. QEMUClockType type;
  47. bool enabled;
  48. } QEMUClock;
  49. QEMUTimerListGroup main_loop_tlg;
  50. static QEMUClock qemu_clocks[QEMU_CLOCK_MAX];
  51. /* A QEMUTimerList is a list of timers attached to a clock. More
  52. * than one QEMUTimerList can be attached to each clock, for instance
  53. * used by different AioContexts / threads. Each clock also has
  54. * a list of the QEMUTimerLists associated with it, in order that
  55. * reenabling the clock can call all the notifiers.
  56. */
  57. struct QEMUTimerList {
  58. QEMUClock *clock;
  59. QemuMutex active_timers_lock;
  60. QEMUTimer *active_timers;
  61. QLIST_ENTRY(QEMUTimerList) list;
  62. QEMUTimerListNotifyCB *notify_cb;
  63. void *notify_opaque;
  64. /* lightweight method to mark the end of timerlist's running */
  65. QemuEvent timers_done_ev;
  66. };
  67. /**
  68. * qemu_clock_ptr:
  69. * @type: type of clock
  70. *
  71. * Translate a clock type into a pointer to QEMUClock object.
  72. *
  73. * Returns: a pointer to the QEMUClock object
  74. */
  75. static inline QEMUClock *qemu_clock_ptr(QEMUClockType type)
  76. {
  77. return &qemu_clocks[type];
  78. }
  79. static bool timer_expired_ns(QEMUTimer *timer_head, int64_t current_time)
  80. {
  81. return timer_head && (timer_head->expire_time <= current_time);
  82. }
  83. QEMUTimerList *timerlist_new(QEMUClockType type,
  84. QEMUTimerListNotifyCB *cb,
  85. void *opaque)
  86. {
  87. QEMUTimerList *timer_list;
  88. QEMUClock *clock = qemu_clock_ptr(type);
  89. timer_list = g_malloc0(sizeof(QEMUTimerList));
  90. qemu_event_init(&timer_list->timers_done_ev, true);
  91. timer_list->clock = clock;
  92. timer_list->notify_cb = cb;
  93. timer_list->notify_opaque = opaque;
  94. qemu_mutex_init(&timer_list->active_timers_lock);
  95. QLIST_INSERT_HEAD(&clock->timerlists, timer_list, list);
  96. return timer_list;
  97. }
  98. void timerlist_free(QEMUTimerList *timer_list)
  99. {
  100. assert(!timerlist_has_timers(timer_list));
  101. if (timer_list->clock) {
  102. QLIST_REMOVE(timer_list, list);
  103. }
  104. qemu_mutex_destroy(&timer_list->active_timers_lock);
  105. g_free(timer_list);
  106. }
  107. static void qemu_clock_init(QEMUClockType type, QEMUTimerListNotifyCB *notify_cb)
  108. {
  109. QEMUClock *clock = qemu_clock_ptr(type);
  110. /* Assert that the clock of type TYPE has not been initialized yet. */
  111. assert(main_loop_tlg.tl[type] == NULL);
  112. clock->type = type;
  113. clock->enabled = (type == QEMU_CLOCK_VIRTUAL ? false : true);
  114. clock->last = INT64_MIN;
  115. QLIST_INIT(&clock->timerlists);
  116. notifier_list_init(&clock->reset_notifiers);
  117. main_loop_tlg.tl[type] = timerlist_new(type, notify_cb, NULL);
  118. }
  119. bool qemu_clock_use_for_deadline(QEMUClockType type)
  120. {
  121. return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));
  122. }
  123. void qemu_clock_notify(QEMUClockType type)
  124. {
  125. QEMUTimerList *timer_list;
  126. QEMUClock *clock = qemu_clock_ptr(type);
  127. QLIST_FOREACH(timer_list, &clock->timerlists, list) {
  128. timerlist_notify(timer_list);
  129. }
  130. }
  131. /* Disabling the clock will wait for related timerlists to stop
  132. * executing qemu_run_timers. Thus, this functions should not
  133. * be used from the callback of a timer that is based on @clock.
  134. * Doing so would cause a deadlock.
  135. *
  136. * Caller should hold BQL.
  137. */
  138. void qemu_clock_enable(QEMUClockType type, bool enabled)
  139. {
  140. QEMUClock *clock = qemu_clock_ptr(type);
  141. QEMUTimerList *tl;
  142. bool old = clock->enabled;
  143. clock->enabled = enabled;
  144. if (enabled && !old) {
  145. qemu_clock_notify(type);
  146. } else if (!enabled && old) {
  147. QLIST_FOREACH(tl, &clock->timerlists, list) {
  148. qemu_event_wait(&tl->timers_done_ev);
  149. }
  150. }
  151. }
  152. bool timerlist_has_timers(QEMUTimerList *timer_list)
  153. {
  154. return !!atomic_read(&timer_list->active_timers);
  155. }
  156. bool qemu_clock_has_timers(QEMUClockType type)
  157. {
  158. return timerlist_has_timers(
  159. main_loop_tlg.tl[type]);
  160. }
  161. bool timerlist_expired(QEMUTimerList *timer_list)
  162. {
  163. int64_t expire_time;
  164. if (!atomic_read(&timer_list->active_timers)) {
  165. return false;
  166. }
  167. qemu_mutex_lock(&timer_list->active_timers_lock);
  168. if (!timer_list->active_timers) {
  169. qemu_mutex_unlock(&timer_list->active_timers_lock);
  170. return false;
  171. }
  172. expire_time = timer_list->active_timers->expire_time;
  173. qemu_mutex_unlock(&timer_list->active_timers_lock);
  174. return expire_time <= qemu_clock_get_ns(timer_list->clock->type);
  175. }
  176. bool qemu_clock_expired(QEMUClockType type)
  177. {
  178. return timerlist_expired(
  179. main_loop_tlg.tl[type]);
  180. }
  181. /*
  182. * As above, but return -1 for no deadline, and do not cap to 2^32
  183. * as we know the result is always positive.
  184. */
  185. int64_t timerlist_deadline_ns(QEMUTimerList *timer_list)
  186. {
  187. int64_t delta;
  188. int64_t expire_time;
  189. if (!atomic_read(&timer_list->active_timers)) {
  190. return -1;
  191. }
  192. if (!timer_list->clock->enabled) {
  193. return -1;
  194. }
  195. /* The active timers list may be modified before the caller uses our return
  196. * value but ->notify_cb() is called when the deadline changes. Therefore
  197. * the caller should notice the change and there is no race condition.
  198. */
  199. qemu_mutex_lock(&timer_list->active_timers_lock);
  200. if (!timer_list->active_timers) {
  201. qemu_mutex_unlock(&timer_list->active_timers_lock);
  202. return -1;
  203. }
  204. expire_time = timer_list->active_timers->expire_time;
  205. qemu_mutex_unlock(&timer_list->active_timers_lock);
  206. delta = expire_time - qemu_clock_get_ns(timer_list->clock->type);
  207. if (delta <= 0) {
  208. return 0;
  209. }
  210. return delta;
  211. }
  212. /* Calculate the soonest deadline across all timerlists attached
  213. * to the clock. This is used for the icount timeout so we
  214. * ignore whether or not the clock should be used in deadline
  215. * calculations.
  216. */
  217. int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
  218. {
  219. int64_t deadline = -1;
  220. QEMUTimerList *timer_list;
  221. QEMUClock *clock = qemu_clock_ptr(type);
  222. QLIST_FOREACH(timer_list, &clock->timerlists, list) {
  223. deadline = qemu_soonest_timeout(deadline,
  224. timerlist_deadline_ns(timer_list));
  225. }
  226. return deadline;
  227. }
  228. QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list)
  229. {
  230. return timer_list->clock->type;
  231. }
  232. QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClockType type)
  233. {
  234. return main_loop_tlg.tl[type];
  235. }
  236. void timerlist_notify(QEMUTimerList *timer_list)
  237. {
  238. if (timer_list->notify_cb) {
  239. timer_list->notify_cb(timer_list->notify_opaque, timer_list->clock->type);
  240. } else {
  241. qemu_notify_event();
  242. }
  243. }
  244. /* Transition function to convert a nanosecond timeout to ms
  245. * This is used where a system does not support ppoll
  246. */
  247. int qemu_timeout_ns_to_ms(int64_t ns)
  248. {
  249. int64_t ms;
  250. if (ns < 0) {
  251. return -1;
  252. }
  253. if (!ns) {
  254. return 0;
  255. }
  256. /* Always round up, because it's better to wait too long than to wait too
  257. * little and effectively busy-wait
  258. */
  259. ms = DIV_ROUND_UP(ns, SCALE_MS);
  260. /* To avoid overflow problems, limit this to 2^31, i.e. approx 25 days */
  261. if (ms > (int64_t) INT32_MAX) {
  262. ms = INT32_MAX;
  263. }
  264. return (int) ms;
  265. }
  266. /* qemu implementation of g_poll which uses a nanosecond timeout but is
  267. * otherwise identical to g_poll
  268. */
  269. int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
  270. {
  271. #ifdef CONFIG_PPOLL
  272. if (timeout < 0) {
  273. return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
  274. } else {
  275. struct timespec ts;
  276. int64_t tvsec = timeout / 1000000000LL;
  277. /* Avoid possibly overflowing and specifying a negative number of
  278. * seconds, which would turn a very long timeout into a busy-wait.
  279. */
  280. if (tvsec > (int64_t)INT32_MAX) {
  281. tvsec = INT32_MAX;
  282. }
  283. ts.tv_sec = tvsec;
  284. ts.tv_nsec = timeout % 1000000000LL;
  285. return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
  286. }
  287. #else
  288. return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
  289. #endif
  290. }
  291. void timer_init_tl(QEMUTimer *ts,
  292. QEMUTimerList *timer_list, int scale,
  293. QEMUTimerCB *cb, void *opaque)
  294. {
  295. ts->timer_list = timer_list;
  296. ts->cb = cb;
  297. ts->opaque = opaque;
  298. ts->scale = scale;
  299. ts->expire_time = -1;
  300. }
  301. void timer_deinit(QEMUTimer *ts)
  302. {
  303. assert(ts->expire_time == -1);
  304. ts->timer_list = NULL;
  305. }
  306. static void timer_del_locked(QEMUTimerList *timer_list, QEMUTimer *ts)
  307. {
  308. QEMUTimer **pt, *t;
  309. ts->expire_time = -1;
  310. pt = &timer_list->active_timers;
  311. for(;;) {
  312. t = *pt;
  313. if (!t)
  314. break;
  315. if (t == ts) {
  316. atomic_set(pt, t->next);
  317. break;
  318. }
  319. pt = &t->next;
  320. }
  321. }
  322. static bool timer_mod_ns_locked(QEMUTimerList *timer_list,
  323. QEMUTimer *ts, int64_t expire_time)
  324. {
  325. QEMUTimer **pt, *t;
  326. /* add the timer in the sorted list */
  327. pt = &timer_list->active_timers;
  328. for (;;) {
  329. t = *pt;
  330. if (!timer_expired_ns(t, expire_time)) {
  331. break;
  332. }
  333. pt = &t->next;
  334. }
  335. ts->expire_time = MAX(expire_time, 0);
  336. ts->next = *pt;
  337. atomic_set(pt, ts);
  338. return pt == &timer_list->active_timers;
  339. }
  340. static void timerlist_rearm(QEMUTimerList *timer_list)
  341. {
  342. /* Interrupt execution to force deadline recalculation. */
  343. if (timer_list->clock->type == QEMU_CLOCK_VIRTUAL) {
  344. qemu_start_warp_timer();
  345. }
  346. timerlist_notify(timer_list);
  347. }
  348. /* stop a timer, but do not dealloc it */
  349. void timer_del(QEMUTimer *ts)
  350. {
  351. QEMUTimerList *timer_list = ts->timer_list;
  352. if (timer_list) {
  353. qemu_mutex_lock(&timer_list->active_timers_lock);
  354. timer_del_locked(timer_list, ts);
  355. qemu_mutex_unlock(&timer_list->active_timers_lock);
  356. }
  357. }
  358. /* modify the current timer so that it will be fired when current_time
  359. >= expire_time. The corresponding callback will be called. */
  360. void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)
  361. {
  362. QEMUTimerList *timer_list = ts->timer_list;
  363. bool rearm;
  364. qemu_mutex_lock(&timer_list->active_timers_lock);
  365. timer_del_locked(timer_list, ts);
  366. rearm = timer_mod_ns_locked(timer_list, ts, expire_time);
  367. qemu_mutex_unlock(&timer_list->active_timers_lock);
  368. if (rearm) {
  369. timerlist_rearm(timer_list);
  370. }
  371. }
  372. /* modify the current timer so that it will be fired when current_time
  373. >= expire_time or the current deadline, whichever comes earlier.
  374. The corresponding callback will be called. */
  375. void timer_mod_anticipate_ns(QEMUTimer *ts, int64_t expire_time)
  376. {
  377. QEMUTimerList *timer_list = ts->timer_list;
  378. bool rearm;
  379. qemu_mutex_lock(&timer_list->active_timers_lock);
  380. if (ts->expire_time == -1 || ts->expire_time > expire_time) {
  381. if (ts->expire_time != -1) {
  382. timer_del_locked(timer_list, ts);
  383. }
  384. rearm = timer_mod_ns_locked(timer_list, ts, expire_time);
  385. } else {
  386. rearm = false;
  387. }
  388. qemu_mutex_unlock(&timer_list->active_timers_lock);
  389. if (rearm) {
  390. timerlist_rearm(timer_list);
  391. }
  392. }
  393. void timer_mod(QEMUTimer *ts, int64_t expire_time)
  394. {
  395. timer_mod_ns(ts, expire_time * ts->scale);
  396. }
  397. void timer_mod_anticipate(QEMUTimer *ts, int64_t expire_time)
  398. {
  399. timer_mod_anticipate_ns(ts, expire_time * ts->scale);
  400. }
  401. bool timer_pending(QEMUTimer *ts)
  402. {
  403. return ts->expire_time >= 0;
  404. }
  405. bool timer_expired(QEMUTimer *timer_head, int64_t current_time)
  406. {
  407. return timer_expired_ns(timer_head, current_time * timer_head->scale);
  408. }
  409. bool timerlist_run_timers(QEMUTimerList *timer_list)
  410. {
  411. QEMUTimer *ts;
  412. int64_t current_time;
  413. bool progress = false;
  414. QEMUTimerCB *cb;
  415. void *opaque;
  416. if (!atomic_read(&timer_list->active_timers)) {
  417. return false;
  418. }
  419. qemu_event_reset(&timer_list->timers_done_ev);
  420. if (!timer_list->clock->enabled) {
  421. goto out;
  422. }
  423. switch (timer_list->clock->type) {
  424. case QEMU_CLOCK_REALTIME:
  425. break;
  426. default:
  427. case QEMU_CLOCK_VIRTUAL:
  428. if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) {
  429. goto out;
  430. }
  431. break;
  432. case QEMU_CLOCK_HOST:
  433. if (!replay_checkpoint(CHECKPOINT_CLOCK_HOST)) {
  434. goto out;
  435. }
  436. break;
  437. case QEMU_CLOCK_VIRTUAL_RT:
  438. if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL_RT)) {
  439. goto out;
  440. }
  441. break;
  442. }
  443. current_time = qemu_clock_get_ns(timer_list->clock->type);
  444. for(;;) {
  445. qemu_mutex_lock(&timer_list->active_timers_lock);
  446. ts = timer_list->active_timers;
  447. if (!timer_expired_ns(ts, current_time)) {
  448. qemu_mutex_unlock(&timer_list->active_timers_lock);
  449. break;
  450. }
  451. /* remove timer from the list before calling the callback */
  452. timer_list->active_timers = ts->next;
  453. ts->next = NULL;
  454. ts->expire_time = -1;
  455. cb = ts->cb;
  456. opaque = ts->opaque;
  457. qemu_mutex_unlock(&timer_list->active_timers_lock);
  458. /* run the callback (the timer list can be modified) */
  459. cb(opaque);
  460. progress = true;
  461. }
  462. out:
  463. qemu_event_set(&timer_list->timers_done_ev);
  464. return progress;
  465. }
  466. bool qemu_clock_run_timers(QEMUClockType type)
  467. {
  468. return timerlist_run_timers(main_loop_tlg.tl[type]);
  469. }
  470. void timerlistgroup_init(QEMUTimerListGroup *tlg,
  471. QEMUTimerListNotifyCB *cb, void *opaque)
  472. {
  473. QEMUClockType type;
  474. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  475. tlg->tl[type] = timerlist_new(type, cb, opaque);
  476. }
  477. }
  478. void timerlistgroup_deinit(QEMUTimerListGroup *tlg)
  479. {
  480. QEMUClockType type;
  481. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  482. timerlist_free(tlg->tl[type]);
  483. }
  484. }
  485. bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg)
  486. {
  487. QEMUClockType type;
  488. bool progress = false;
  489. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  490. progress |= timerlist_run_timers(tlg->tl[type]);
  491. }
  492. return progress;
  493. }
  494. int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
  495. {
  496. int64_t deadline = -1;
  497. QEMUClockType type;
  498. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  499. if (qemu_clock_use_for_deadline(type)) {
  500. deadline = qemu_soonest_timeout(deadline,
  501. timerlist_deadline_ns(tlg->tl[type]));
  502. }
  503. }
  504. return deadline;
  505. }
  506. int64_t qemu_clock_get_ns(QEMUClockType type)
  507. {
  508. int64_t now, last;
  509. QEMUClock *clock = qemu_clock_ptr(type);
  510. switch (type) {
  511. case QEMU_CLOCK_REALTIME:
  512. return get_clock();
  513. default:
  514. case QEMU_CLOCK_VIRTUAL:
  515. if (use_icount) {
  516. return cpu_get_icount();
  517. } else {
  518. return cpu_get_clock();
  519. }
  520. case QEMU_CLOCK_HOST:
  521. now = REPLAY_CLOCK(REPLAY_CLOCK_HOST, get_clock_realtime());
  522. last = clock->last;
  523. clock->last = now;
  524. if (now < last || now > (last + get_max_clock_jump())) {
  525. notifier_list_notify(&clock->reset_notifiers, &now);
  526. }
  527. return now;
  528. case QEMU_CLOCK_VIRTUAL_RT:
  529. return REPLAY_CLOCK(REPLAY_CLOCK_VIRTUAL_RT, cpu_get_clock());
  530. }
  531. }
  532. uint64_t qemu_clock_get_last(QEMUClockType type)
  533. {
  534. QEMUClock *clock = qemu_clock_ptr(type);
  535. return clock->last;
  536. }
  537. void qemu_clock_set_last(QEMUClockType type, uint64_t last)
  538. {
  539. QEMUClock *clock = qemu_clock_ptr(type);
  540. clock->last = last;
  541. }
  542. void qemu_clock_register_reset_notifier(QEMUClockType type,
  543. Notifier *notifier)
  544. {
  545. QEMUClock *clock = qemu_clock_ptr(type);
  546. notifier_list_add(&clock->reset_notifiers, notifier);
  547. }
  548. void qemu_clock_unregister_reset_notifier(QEMUClockType type,
  549. Notifier *notifier)
  550. {
  551. notifier_remove(notifier);
  552. }
  553. void init_clocks(QEMUTimerListNotifyCB *notify_cb)
  554. {
  555. QEMUClockType type;
  556. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  557. qemu_clock_init(type, notify_cb);
  558. }
  559. #ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK
  560. prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
  561. #endif
  562. }
  563. uint64_t timer_expire_time_ns(QEMUTimer *ts)
  564. {
  565. return timer_pending(ts) ? ts->expire_time : -1;
  566. }
  567. bool qemu_clock_run_all_timers(void)
  568. {
  569. bool progress = false;
  570. QEMUClockType type;
  571. for (type = 0; type < QEMU_CLOCK_MAX; type++) {
  572. if (qemu_clock_use_for_deadline(type)) {
  573. progress |= qemu_clock_run_timers(type);
  574. }
  575. }
  576. return progress;
  577. }