aboutsummaryrefslogtreecommitdiff
path: root/main-loop.c
AgeCommit message (Collapse)AuthorFilesLines
2012-05-01main-loop: Calculate poll timeout using timeout argumentStefan Weil1-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>
2012-04-28main-loop: Fix build for w32 and w64Stefan Weil1-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>
2012-04-26main_loop_wait: block indefinitelyStefano Stabellini1-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>
2012-04-15w64: Fix type cast in os_host_main_loop_waitStefan Weil1-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>
2012-04-10Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori1-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
2012-04-07main-loop: integrate glib sources for w32Paolo Bonzini1-6/+15
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-07main-loop: replace WaitForMultipleObjects with g_pollPaolo Bonzini1-23/+17
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>
2012-04-07main-loop: interrupt wait when data arrives on a socketPaolo Bonzini1-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>
2012-04-07main-loop: disable fd_set-based glib integration under w32Paolo Bonzini1-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>
2012-04-07main loop: use msec-based timeout in glib_select_fillPaolo Bonzini1-12/+10
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>
2012-04-03main-loop: make qemu_event_handle staticFrediano Ziglio1-1/+1
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-02-01main-loop: For tools, initialize timers as part of qemu_init_main_loop()Michael Roth1-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>
2012-02-01main-loop: Fix SetEvent() on uninitialized handle on win32Michael Roth1-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>
2012-01-12cleanup, save a syscallLai Jiangshan1-3/+1
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-25main-loop: Add missing include fileStefan Weil1-25/+5
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>
2011-10-21main-loop: create main-loop.cPaolo Bonzini1-0/+495
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>