Statistics
| Branch: | Revision:

root / main-loop.c @ feature-archipelago

History | View | Annotate | Download (13.5 kB)

# Date Author Comment
a42e9c41 09/17/2013 01:26 pm Liu Ping Fan

slirp: set mainloop timeout with more precise value

If slirp needs to emulate tcp timeout, then the timeout value
for mainloop should be more precise, which is determined by
slirp's fasttimo or slowtimo. Achieve this by swap the logic
sequence of slirp_pollfds_fill and slirp_update_timeout....

40daca54 08/22/2013 08:14 pm Alex Bligh

aio / timers: Rearrange timer.h & make legacy functions call non-legacy

Rearrange timer.h so it is in order by function type.

Make legacy functions call non-legacy functions rather than vice-versa.

Convert cpus.c to use new API.

Signed-off-by: Alex Bligh <>...

6d327171 08/22/2013 08:10 pm Alex Bligh

aio / timers: Remove alarm timers

Remove alarm timers from qemu-timers.c now we use g_poll / ppoll
instead.

Signed-off-by: Alex Bligh <>
Signed-off-by: Stefan Hajnoczi <>

7b595f35 08/22/2013 08:10 pm Alex Bligh

aio / timers: Convert mainloop to use timeout

Convert mainloop to use timeout from default timerlist group
(i.e. the current 3 static timers)

main-loop.c produces a (possibly spurious) warning about
multiple iterations. Adapt the way this works for a signed...

f2e5dca4 08/19/2013 04:52 pm Stefan Hajnoczi

aio: drop io_flush argument

The .io_flush() handler no longer exists and has no users. Drop the
io_flush argument to aio_set_fd_handler() and related functions.

The AioFlushEventNotifierHandler and AioFlushHandler typedefs are no
longer used and are dropped too....

520b6dd4 06/12/2013 05:43 pm Michael Tokarev

main-loop: do not include slirp/slirp.h, use libslirp.h instead

The header slirp/slirp.h is an internal header for slirp, and
main-loop.c does not use internals from there. Instead, it uses
public functions (slirp_update_timeout(), slirp_pollfds_fill()
etc) which are declared in slirp/libslirp.h....

8db165b3 05/16/2013 10:18 pm Stefan Hajnoczi

main-loop: narrow win32 pollfds_fill() event bitmasks

pollfds_fill() and pollfds_poll() translate GPollFD to rfds/wfds/xfds
for sockets on win32. select(2) is the underlying system call which is
used to monitor sockets for activity.

Currently file descriptors that monitor G_IO_ERR will be included in...

3cb8c205 05/16/2013 10:18 pm Stefan Hajnoczi

main-loop: partial revert of 5e3bc73

This patch reverts part of 5e3bc735d93dd23f074b5116fd11e1ad8cd4962f.

Paolo Bonzini wrote this patch and commented:

"WSAEventSelect is edge-triggered and the event will not be signaled if
the socket handler does not consume all the data in the socket buffer."...

893986fe 04/05/2013 08:53 pm Anthony Liguori

main-loop: drop the BQL if the I/O appears to be spinning

The char-flow refactoring introduced a busy-wait that depended on
an action from the VCPU thread. However, the VCPU thread could
never take that action because the busy-wait starved the VCPU thread...

5f3aa1ff 03/15/2013 05:07 pm Stefan Hajnoczi

main-loop: add qemu_get_aio_context()

It is very useful to get the main loop AioContext, which is a static
variable in main-loop.c.

I'm not sure whether qemu_get_aio_context() will be necessary in the
future once devices focus on using their own AioContext instead of the...

8917c3bd 02/22/2013 12:17 am Stefan Hajnoczi

slirp: switch to GPollFD

Slirp uses rfds/wfds/xfds more extensively than other QEMU components.

The rarely-used out-of-band TCP data feature is used. That means we
need the full table of select(2) to g_poll(3) events:

rfds -> G_IO_IN | G_IO_HUP | G_IO_ERR...
a3e4b4a8 02/22/2013 12:17 am Stefan Hajnoczi

iohandler: switch to GPollFD

Convert iohandler_select_fill() and iohandler_select_poll() to use
GPollFD instead of rfds/wfds/xfds.

Signed-off-by: Stefan Hajnoczi <>
Reviewed-by: Laszlo Ersek <>
Message-id: ...

9cbaacf9 02/22/2013 12:17 am Stefan Hajnoczi

main-loop: drop rfds/wfds/xfds for good

Now that all *_fill() and *_poll() functions use GPollFD we no longer
need rfds/wfds/xfds or pollfds_from_select()/pollfds_to_select().

From now on everything uses GPollFD.

Signed-off-by: Stefan Hajnoczi <>...

134a03e0 02/22/2013 12:17 am Stefan Hajnoczi

main-loop: fix select_ret uninitialized variable warning

Signed-off-by: Stefan Hajnoczi <>
Reviewed-by: Laszlo Ersek <>
Message-id:
Signed-off-by: Anthony Liguori <>

cbff4b34 02/22/2013 12:17 am Stefan Hajnoczi

main-loop: switch to g_poll() on POSIX hosts

Use g_poll(3) instead of select(2). Well, this is kind of a cheat.
It's true that we're now using g_poll(3) on POSIX hosts but the *_fill()
and *_poll() functions are still using rfds/wfds/xfds.

We've set the scene to start converting *_fill() and *_poll() functions...

48ce11ff 02/22/2013 12:17 am Stefan Hajnoczi

main-loop: switch POSIX glib integration to GPollFD

Convert glib file descriptor polling from rfds/wfds/xfds to GPollFD.

The Windows code still needs poll_fds[] and n_poll_fds but they can now
become local variables.

Signed-off-by: Stefan Hajnoczi <>...

5e3bc735 01/09/2013 07:03 pm Fabien Chouteau

Check return values from g_poll and select

The current implementation of os_host_main_loop_wait() on Windows,
returns 1 only when a g_poll() event occurs because the return value of
select() is overridden. This is wrong as we may skip a socket event, as
shown in this example:...

1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

c57b6656 12/11/2012 12:04 pm Kevin Wolf

aio: Get rid of qemu_aio_flush()

There are no remaining users, and new users should probably be
using bdrv_drain_all() in the first place.

Signed-off-by: Kevin Wolf <>

49cf5728 11/02/2012 08:07 pm Paolo Bonzini

vl: delay thread initialization after daemonization

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....

f9ab4654 11/02/2012 08:07 pm Paolo Bonzini

vl: unify calls to init_timer_alarm

init_timer_alarm was being called twice. This is not needed.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

4c8d0d27 10/30/2012 10:30 am Paolo Bonzini

main-loop: use aio_notify for qemu_notify_event

Reviewed-by: Anthony Liguori <>
Signed-off-by: Paolo Bonzini <>

f627aab1 10/30/2012 10:30 am Paolo Bonzini

aio: introduce AioContext, move bottom halves there

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...

a915f4bc 10/30/2012 10:30 am Paolo Bonzini

aio: add I/O handlers to the AioContext interface

With this patch, I/O handlers (including event notifier handlers) can be
attached to a single AioContext.

Signed-off-by: Paolo Bonzini <>

7c0628b2 10/30/2012 10:30 am Paolo Bonzini

aio: add non-blocking variant of aio_wait

This will be used when polling the GSource attached to an AioContext.

Reviewed-by: Anthony Liguori <>
Signed-off-by: Paolo Bonzini <>

f42b2207 10/30/2012 10:30 am Paolo Bonzini

aio: add Win32 implementation

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....

82cbbdc6 10/30/2012 10:30 am Paolo Bonzini

main-loop: use GSource to poll AIO file descriptors

This lets us remove the hooks for the main loop in async.c.

Reviewed-by: Anthony Liguori <>
Signed-off-by: Paolo Bonzini <>

172061a0 10/30/2012 10:18 am Paolo Bonzini

main-loop: unify qemu_init_main_loop between QEMU and tools

Signed-off-by: Paolo Bonzini <>

3239ad04 05/01/2012 01:46 pm Stefan Weil

main-loop: Calculate poll timeout using timeout argument

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 <>
Reviewed-by: Paolo Bonzini <>...

42fe1c24 04/28/2012 12:25 pm Stefan Weil

main-loop: Fix build for w32 and w64

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....

7c7db755 04/26/2012 09:14 pm Stefano Stabellini

main_loop_wait: block indefinitely

- 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 <>...

58b9630d 04/15/2012 10:25 pm Stefan Weil

w64: Fix type cast in os_host_main_loop_wait

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 <>

72fe3aae 04/10/2012 04:10 pm Anthony Liguori

Merge remote-tracking branch 'stefanha/trivial-patches' into staging

  • 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'...
ea26ce76 04/07/2012 11:34 am Paolo Bonzini

main-loop: integrate glib sources for w32

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Blue Swirl <>

06ac7d49 04/07/2012 11:34 am Paolo Bonzini

main-loop: replace WaitForMultipleObjects with g_poll

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....

d3385eb4 04/07/2012 11:34 am Paolo Bonzini

main-loop: interrupt wait when data arrives on a socket

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...

4dae83ae 04/07/2012 11:34 am Paolo Bonzini

main loop: use msec-based timeout in glib_select_fill

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 <>...

15455536 04/07/2012 11:34 am Paolo Bonzini

main-loop: disable fd_set-based glib integration under w32

Using select with glib pollfds is wrong under w32. Restrict
the code to the POSIX case.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Blue Swirl <>

a92433af 04/03/2012 11:34 am Frediano Ziglio

main-loop: make qemu_event_handle static

Signed-off-by: Frediano Ziglio <>
Signed-off-by: Stefan Hajnoczi <>

ee77dfb2 02/01/2012 10:45 pm Michael Roth

main-loop: Fix SetEvent() on uninitialized handle on win32

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...

d34e8f6e 02/01/2012 10:45 pm Michael Roth

main-loop: For tools, initialize timers as part of qemu_init_main_loop()

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...

4aa7534d 01/12/2012 06:34 pm Lai Jiangshan

cleanup, save a syscall

Signed-off-by: Lai Jiangshan <>
Signed-off-by: Anthony Liguori <>

0ec024f6 10/25/2011 11:38 pm Stefan Weil

main-loop: Add missing include file

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 <>...

d3b12f5d 10/21/2011 07:14 pm Paolo Bonzini

main-loop: create main-loop.c

Signed-off-by: Paolo Bonzini <>