summaryrefslogtreecommitdiffstats
path: root/main-loop.c
Commit message (Collapse)AuthorAgeFilesLines
* aio: Get rid of qemu_aio_flush()Kevin Wolf2012-12-111-5/+0Star
| | | | | | | There are no remaining users, and new users should probably be using bdrv_drain_all() in the first place. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vl: delay thread initialization after daemonizationPaolo Bonzini2012-11-021-1/+0Star
| | | | | | | | | | | | | | | | | | Commit ac4119c (chardev: Use timer instead of bottom-half to postpone open event, 2012-10-12) moved the alarm timer initialization to an earlier point but failed to consider that it depends on qemu_init_main_loop. Later, commit 1c53786 (vl: init main loop earlier, 2012-10-30) fixed this, but left -daemonize in two different ways. First, timers need to be reinitialized after forking. Second, the global mutex was being held by the parent, and thus dropped after forking. The first is now fixed using pthread_atfork. For the second part, make sure that the global mutex is not taken before daemonization, and similarly delay qemu_thread_self. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vl: unify calls to init_timer_alarmPaolo Bonzini2012-11-021-1/+4
| | | | | | | init_timer_alarm was being called twice. This is not needed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* main-loop: use aio_notify for qemu_notify_eventPaolo Bonzini2012-10-301-98/+8Star
| | | | | Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: use GSource to poll AIO file descriptorsPaolo Bonzini2012-10-301-17/+6Star
| | | | | | | This lets us remove the hooks for the main loop in async.c. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* aio: add Win32 implementationPaolo Bonzini2012-10-301-1/+1
| | | | | | | | | The Win32 implementation will only accept EventNotifiers, thus a few drivers are disabled under Windows. EventNotifiers are a good match for the GSource implementation, too, because the Win32 port of glib allows to place their HANDLEs in a GPollFD. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* aio: add non-blocking variant of aio_waitPaolo Bonzini2012-10-301-1/+1
| | | | | | | This will be used when polling the GSource attached to an AioContext. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* aio: add I/O handlers to the AioContext interfacePaolo Bonzini2012-10-301-0/+33
| | | | | | | With this patch, I/O handlers (including event notifier handlers) can be attached to a single AioContext. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* aio: introduce AioContext, move bottom halves therePaolo Bonzini2012-10-301-1/+17
| | | | | | | | | | | | Start introducing AioContext, which will let us remove globals from aio.c/async.c, and introduce multiple I/O threads. The bottom half functions now take an additional AioContext argument. A bottom half is created with a specific AioContext that remains the same throughout the lifetime. qemu_bh_new is just a wrapper that uses a global context. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: unify qemu_init_main_loop between QEMU and toolsPaolo Bonzini2012-10-301-1/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: Calculate poll timeout using timeout argumentStefan Weil2012-05-011-1/+5
| | | | | | | | | | The timeout argument was unused up to now, but it can be used to reduce the poll_timeout when it is infinite (negative value) or larger than timeout. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* main-loop: Fix build for w32 and w64Stefan Weil2012-04-281-3/+4
| | | | | | | | | | | | | | This patch fixes a build regression with MinGW which was introduced by commit 7c7db75576bd5a31508208f153c5aada64b2c8df. The 3rd argument of g_main_context_query must point to a gint value. Using a pointer to an uint32_t value is wrong. The timeout argument of function os_host_main_loop_wait was never used for w32 / w64. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* main_loop_wait: block indefinitelyStefano Stabellini2012-04-261-9/+14
| | | | | | | | | | | | | | | - remove qemu_calculate_timeout; - explicitly size timeout to uint32_t; - introduce slirp_update_timeout; - pass NULL as timeout argument to select in case timeout is the maximum value; Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Paul Brook <paul@codesourcery.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* w64: Fix type cast in os_host_main_loop_waitStefan Weil2012-04-151-1/+1
| | | | | | | Casting a pointer to an integer must use (DWORD_PTR) instead of (DWORD). This also matches the definition of 'fd' (gint for w32, gint64 for w64). Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori2012-04-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | * stefanha/trivial-patches: make: fix clean rule by removing build file in qom/ configure: Link qga against UST tracing related libraries configure: Link QEMU against 'liburcu-bp' main-loop: make qemu_event_handle static block/curl: Replace usleep by g_usleep qtest: Add missing GCC_FMT_ATTR w32: Undefine error constants before their redefinition configure: fix mingw32 libs_qga typo
| * main-loop: make qemu_event_handle staticFrediano Ziglio2012-04-031-1/+1
| | | | | | | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* | main-loop: integrate glib sources for w32Paolo Bonzini2012-04-071-6/+15
| | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* | main-loop: replace WaitForMultipleObjects with g_pollPaolo Bonzini2012-04-071-23/+17Star
| | | | | | | | | | | | | | | | | | | | On w32, glib implements g_poll using WaitForMultipleObjects or MsgWaitForMultipleObjects. This means that we can simplify our code by switching to g_poll, and at the same time prepare for adding back glib sources. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* | main-loop: interrupt wait when data arrives on a socketPaolo Bonzini2012-04-071-25/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, the main loop is not interrupted when data arrives on a socket. To fix this, register each socket to interrupt the main loop with WSAEventSelect. This does not replace select, it only communicates a change in socket state that requires a select call. Since the interrupt fires only once per recv call, or only once after a send call returns EWOULDBLOCK we can activate it on all events unconditionally. If QEMU is momentarily uninterested on some condition, the main loop will not busy wait. Instead, it may get one extra wakeup, but then it will ignore the condition until progress occurs and/or qemu_set_fd_handler is called to set a callback. At this point the condition will be tested via select and the callback will be invoked even if it is still disabled on the event. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* | main-loop: disable fd_set-based glib integration under w32Paolo Bonzini2012-04-071-30/+33
| | | | | | | | | | | | | | | | Using select with glib pollfds is wrong under w32. Restrict the code to the POSIX case. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* | main loop: use msec-based timeout in glib_select_fillPaolo Bonzini2012-04-071-12/+10Star
|/ | | | | | | | | The timeval-based timeout is not needed until we actually invoke select, so compute it only then. Also group the two calls that modify the timeout, glib_select_fill and os_host_main_loop_wait. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* main-loop: For tools, initialize timers as part of qemu_init_main_loop()Michael Roth2012-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | In some cases initializing the alarm timers can lead to non-negligable overhead from programs that link against qemu-tool.o. At least, setting a max-resolution WinMM alarm timer via mm_start_timer() (the current default for Windows) can increase the "tick rate" on Windows OSs and affect frequency scaling, and in the case of tools that run in guest OSs such has qemu-ga, the impact can be fairly dramatic (+20%/20% user/sys time on a core 2 processor was observed from an idle Windows XP guest). This patch doesn't address the issue directly (not sure what a good solution would be for Windows, or what other situations it might be noticeable), but it at least limits the scope of the issue to programs that "opt-in" to using the main-loop.c functions by only enabling alarm timers when qemu_init_main_loop() is called, which is already required to make use of those facilities, so existing users shouldn't be affected. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* main-loop: Fix SetEvent() on uninitialized handle on win32Michael Roth2012-02-011-1/+4
| | | | | | | | | | | | | | | | | The __attribute__((constructor)) init_main_loop() automatically get called if qemu-tool.o is linked in. On win32, this leads to a qemu_notify_event() call which attempts to SetEvent() on a HANDLE that won't be initialized until qemu_init_main_loop() is manually called, breaking qemu-tools.o programs on Windows at runtime. This patch checks for an initialized event handle before attempting to set it, which is analoguous to how we deal with an unitialized io_thread_fd in the posix implementation. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* cleanup, save a syscallLai Jiangshan2012-01-121-3/+1Star
| | | | | Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* main-loop: Add missing include fileStefan Weil2011-10-251-25/+5Star
| | | | | | | | | | | stdint.h defines the POSIX data types and is needed for MinGW-w64 (and maybe other hosts). v2: Instead of adding stdint.h directly, qemu-common.h is now included and duplicate include statements were removed. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* main-loop: create main-loop.cPaolo Bonzini2011-10-211-0/+495
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>