int main_loop_wait(int nonblocking) { int ret; uint32_t timeout = UINT32_MAX; if (nonblocking) { timeout = 0; } /* poll any events */ /* XXX: separate device handlers from system ones */ nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); #ifdef CONFIG_SLIRP slirp_update_timeout(&timeout); slirp_select_fill(&nfds, &rfds, &wfds, &xfds); #endif qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds); ret = os_host_main_loop_wait(timeout); qemu_iohandler_poll(&rfds, &wfds, &xfds, ret); #ifdef CONFIG_SLIRP slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0)); #endif qemu_run_all_timers(); return ret; }
void main_loop_wait(int timeout) { fd_set rfds, wfds, xfds; int ret, nfds; struct timeval tv; qemu_bh_update_timeout(&timeout); os_host_main_loop_wait(&timeout); tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; /* poll any events */ /* XXX: separate device handlers from system ones */ nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds); if (slirp_is_inited()) { slirp_select_fill(&nfds, &rfds, &wfds, &xfds); } qemu_mutex_unlock_iothread(); ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); qemu_mutex_lock_iothread(); qemu_iohandler_poll(&rfds, &wfds, &xfds, ret); if (slirp_is_inited()) { if (ret < 0) { FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); } slirp_select_poll(&rfds, &wfds, &xfds); } charpipe_poll(); qemu_clock_run_all_timers(); qemu_run_alarm_timer(); /* Check bottom-halves last in case any of the earlier events triggered them. */ qemu_bh_poll(); }
int main_loop_wait(int nonblocking) { int ret; uint32_t timeout = UINT32_MAX; int64_t timeout_ns; if (nonblocking) { timeout = 0; } /* poll any events */ g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ #ifdef CONFIG_SLIRP slirp_update_timeout(&timeout); slirp_pollfds_fill(gpollfds); #endif qemu_iohandler_fill(gpollfds); if (timeout == UINT32_MAX) { timeout_ns = -1; } else { timeout_ns = (uint64_t)timeout * (int64_t)(SCALE_MS); } timeout_ns = qemu_soonest_timeout(timeout_ns, timerlistgroup_deadline_ns( &main_loop_tlg)); ret = os_host_main_loop_wait(timeout_ns); qemu_iohandler_poll(gpollfds, ret); #ifdef CONFIG_SLIRP slirp_pollfds_poll(gpollfds, (ret < 0)); #endif qemu_clock_run_all_timers(); return ret; }
int main_loop_wait(int nonblocking) { int ret; uint32_t timeout = UINT32_MAX; int64_t timeout_ns; if (nonblocking) { timeout = 0; } /* poll any events */ g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ #ifdef CONFIG_SLIRP slirp_pollfds_fill(gpollfds, &timeout); #endif if (timeout == UINT32_MAX) { timeout_ns = -1; } else { timeout_ns = (uint64_t)timeout * (int64_t)(SCALE_MS); } timeout_ns = qemu_soonest_timeout(timeout_ns, timerlistgroup_deadline_ns( &main_loop_tlg)); ret = os_host_main_loop_wait(timeout_ns); #ifdef CONFIG_SLIRP slirp_pollfds_poll(gpollfds, (ret < 0)); #endif /* CPU thread can infinitely wait for event after missing the warp */ qemu_clock_warp(QEMU_CLOCK_VIRTUAL); qemu_clock_run_all_timers(); return ret; }