#include "qemu/timer.h"
#include "qemu/sockets.h" // struct in_addr needed for libslirp.h
#include "sysemu/qtest.h"
+#include "sysemu/cpus.h"
#include "slirp/libslirp.h"
#include "qemu/main-loop.h"
#include "block/aio.h"
+#include "qemu/error-report.h"
#ifndef _WIN32
GSource *src;
Error *local_error = NULL;
- init_clocks();
+ init_clocks(qemu_timer_notify_cb);
ret = qemu_signal_init();
if (ret) {
static int os_host_main_loop_wait(int64_t timeout)
{
+ GMainContext *context = g_main_context_default();
int ret;
static int spin_counter;
+ g_main_context_acquire(context);
+
glib_pollfds_fill(&timeout);
/* If the I/O thread is very busy or we are incorrectly busy waiting in
static bool notified;
if (!notified && !qtest_enabled() && !qtest_driver()) {
- fprintf(stderr,
- "main-loop: WARNING: I/O thread spun for %d iterations\n",
- MAX_MAIN_LOOP_SPIN);
+ warn_report("I/O thread spun for %d iterations",
+ MAX_MAIN_LOOP_SPIN);
notified = true;
}
}
glib_pollfds_poll();
+
+ g_main_context_release(context);
+
return ret;
}
#else
fd_set rfds, wfds, xfds;
int nfds;
+ g_main_context_acquire(context);
+
/* XXX: need to suppress polling by better using win32 events */
ret = 0;
for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret != 0) {
+ g_main_context_release(context);
return ret;
}
g_main_context_dispatch(context);
}
+ g_main_context_release(context);
+
return select_ret || g_poll_ret;
}
#endif
-int main_loop_wait(int nonblocking)
+void main_loop_wait(int nonblocking)
{
int ret;
uint32_t timeout = UINT32_MAX;
/* 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;
&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_start_warp_timer();
qemu_clock_run_all_timers();
-
- return ret;
}
/* Functions to operate on the main QEMU AioContext. */