Statistics
| Branch: | Revision:

root / qemu-timer.c @ 26ca8c06

History | View | Annotate | Download (19.2 kB)

# Date Author Comment
9c17d615 12/19/2012 09:32 am Paolo Bonzini

softmmu: move include files to include/sysemu/

Signed-off-by: Paolo Bonzini <>

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

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

83c9089e 12/19/2012 09:31 am Paolo Bonzini

monitor: move include files to include/monitor/

Signed-off-by: Paolo Bonzini <>

28ecbaee 12/19/2012 09:31 am Paolo Bonzini

ui: move files to ui/ and include/ui/

Signed-off-by: Paolo Bonzini <>

7fa22f2b 12/19/2012 09:29 am Paolo Bonzini

net: do not include net.h everywhere

Signed-off-by: Paolo Bonzini <>

253ecf83 11/10/2012 02:28 pm Stefan Weil

qemu-timer: Fix compilation for non-POSIX hosts

A compiler warning is caused by the unused local function reinit_timers
on non-POSIX hosts. Include that function only for POSIX hosts.

Signed-off-by: Stefan Weil <>
Signed-off-by: Blue Swirl <>

30ea8339 11/04/2012 11:13 pm Anthony Liguori

build: pthread_atfork() needs include of pthread.h

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

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

qemu-timer: reinitialize timers after fork

Timers are not inherited by the child of a fork(2), so just use
pthread_atfork to reinstate them after daemonize.

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

f563a5d7 10/31/2012 11:42 am Paolo Bonzini

Merge remote-tracking branch 'origin/master' into threadpool

Signed-off-by: Paolo Bonzini <>

744ca8e3 10/30/2012 10:18 am Paolo Bonzini

qemu-timer: make initialization functions idempotent

Signed-off-by: Paolo Bonzini <>

1e9737da 10/28/2012 03:54 pm Richard Henderson

qemu-timer: Check for usable fields for SIGEV_THREAD_ID

Older glibc (RHEL 5.x, Debian 5.x) does not have the _sigev_un._tid
member in its structure definition, while the accompanying kernel
headers do define SIGEV_THREAD_ID. We need configure to check for...

144b97c2 09/23/2012 09:11 am Paolo Bonzini

qemu-timer: simplify qemu_run_timers

ptimer_head is an invariant pointer to clock->active_timers.
Remove it, and just reference clock->active_timers directly.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Stefan Hajnoczi <>

de188751 09/04/2012 01:30 pm Paolo Bonzini

qemu-timer: properly arm alarm timer for timers set by device initialization

QEMU will hang when fed the following command-line

qemu-system-mips -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -net none

The -net none is important otherwise it seems some events are generated...

8227421e 08/09/2012 09:42 pm Stefano Stabellini

qemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX

qemu_rearm_alarm_timer partially duplicates the code in
qemu_next_alarm_deadline to figure out if it needs to rearm the timer.
If it calls qemu_next_alarm_deadline, it always rearms the timer even if...

c8057f95 08/02/2012 09:16 pm Peter Maydell

Support 'help' as a synonym for '?' in command line options

For command line options which permit '?' meaning 'please list the
permitted values', add support for 'help' as a synonym, by abstracting
the check out into a helper function.

This change means that in some cases where we were being lazy in...

52ef651f 05/14/2012 08:27 am Stefan Weil

qemu-timer: Fix wrong error message

Function timeSetEvent returns 0 when it fails, but it does not set
an error code which can be retrieved by GetLastError.

Therefore calling GetLastError is useless.

Signed-off-by: Stefan Weil <>

165ceac0 05/08/2012 07:14 pm Andreas Faerber

qemu-timer: Move include for __FreeBSD_version to header

sys/param.h is needed for __FreeBSD_version.
Pointed out by Juergen, thanks.

Signed-off-by: Andreas Faerber <>
Cc: Juergen Lock <>
Signed-off-by: Anthony Liguori <>

40f08e87 05/03/2012 08:04 am Stefan Weil

qemu-timer: Fix limits for w32 mmtimer

timeSetEvent only accepts delays in the range which is returned by
timeGetDevCaps.

The lower limit is typically 1 (= 1 ms), so the constant value of 1
in the old code usually worked.

The upper limit can be as low as 10000 ms, so the latest changes in...

bff9f8bf 04/27/2012 08:39 am Stefan Weil

qemu-timer: Remove redundant include statements

qemu-timer.h includes qemu-common.h which already includes time.h,
sys/time.h, windows.h, unistd.h, fcntl.h, errno.h and signal.h.

Therefore those include statements are redundant and can be removed.

Reviewed-by: Paolo Bonzini <>...

c4879f2a 04/27/2012 08:39 am Stefan Weil

qemu-timer: Remove unused function qemu_alarm_pending

The last user of this function was removed by commit
12d4536f7d911b6d87a766ad7300482ea663cea2.

Reviewed-by: Paolo Bonzini <>
Signed-off-by: Stefan Weil <>

5e1ec7b2 04/27/2012 08:39 am Stefan Weil

qemu-timer: Use bool, false, true for boolean values

This avoids conversions between int and bool / char.

It also makes the code more readable.

Reviewed-by: Paolo Bonzini <>
Signed-off-by: Stefan Weil <>

8205199d 04/27/2012 08:39 am Stefan Weil

qemu-timer: Remove function alarm_has_dynticks

Some time ago, the last time which did not have dynticks was removed,
so now all timers have dynticks.

I also removed a misleading error message for the dynticks timer.
If timer_create fails, there is already an error message, and...

9a14b298 04/27/2012 08:39 am Stefan Weil

qemu-timer: Optimize data structures

Remove all holes which were found by pahole on Linux x86_64
(and replace "struct QEMUTimer" by "QEMUTimer").

Reviewed-by: Paolo Bonzini <>
Signed-off-by: Stefan Weil <>

4ffd16fc 04/26/2012 09:14 pm Stefano Stabellini

qemu_next_alarm_deadline: check the expire time of a clock only if it is enabled

Also delta in qemu_next_alarm_deadline is a 64 bit value so set the
default to INT64_MAX instead of INT32_MAX.

Signed-off-by: Stefano Stabellini <>...

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

5bfb723f 04/26/2012 09:14 pm Stefano Stabellini

timers: the rearm function should be able to handle delta = INT64_MAX

Fix win32_rearm_timer and mm_rearm_timer: they should be able to handle
INT64_MAX as a delta parameter without overflowing.
Also, the next deadline in ms should be calculated rounding down rather...

158fd3ce 04/16/2012 08:56 pm Peter Portante

qemu-timer.c: Remove 250us timeouts

Basically, the main wait loop calls qemu_run_all_timers() unconditionally. The
first thing this routine used to do is to see if a timer had been serviced,
and then reset the loop timeout to the next deadline.

However, the new deadlines had not been calculated at that point, as...

8156be56 03/30/2012 04:14 pm Paolo Bonzini

qtest: add clock management

This patch combines qtest and -icount together to turn the vm_clock
into a source that can be fully managed by the client. To this end new
commands clock_step and clock_set are added. Hooking them with libqtest
is left as an exercise to the reader....

31552529 02/17/2012 04:33 pm Paolo Bonzini

notifier: switch to QLIST

Notifiers do not need to access both ends of the list, and using
a QLIST also simplifies the API.

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

36945d95 01/27/2012 07:29 am Paolo Bonzini

remove #if 0 code for timers

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Stefan Hajnoczi <>

cca5de73 11/09/2011 08:06 pm Paolo Bonzini

win32: remove broken timers

The non-dynticks timer variations are broken, so they can be
removed.

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

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

qemu-timer: move common code to qemu_rearm_alarm_timer

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

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

qemu-timer: more clock functions

These will be used when moving icount accounting to cpus.c.

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

946fb27c 10/21/2011 07:14 pm Paolo Bonzini

qemu-timer: move icount to cpus.c

None of this is needed by tools, and most of it can even be made static
inside cpus.c.

Signed-off-by: Paolo Bonzini <>

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

qemu-timer: do not refer to runstate_is_running()

Signed-off-by: Paolo Bonzini <>

4260a739 10/21/2011 07:14 pm Paolo Bonzini

qemu-timer: use atexit for quit_timers

Signed-off-by: Paolo Bonzini <>

2ff68d07 10/21/2011 07:14 pm Paolo Bonzini

qemu-timer: move more stuff out of qemu-timer.c

Signed-off-by: Paolo Bonzini <>

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

qemu-timer: do not use RunState change handlers

Signed-off-by: Paolo Bonzini <>

688eb389 10/21/2011 07:14 pm Paolo Bonzini

qemu-timer: remove active_timers array

Embed the list in the QEMUClock instead.

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

1dfb4dd9 09/15/2011 10:39 pm Luiz Capitulino

Replace the VMSTOP macros with a proper state type

Today, when notifying a VM state change with vm_state_notify(),
we pass a VMSTOP macro as the 'reason' argument. This is not ideal
because the VMSTOP macros tell why qemu stopped and not exactly
what the current VM state is....

1354869c 09/15/2011 10:39 pm Luiz Capitulino

Drop the vm_running global variable

Use runstate_is_running() instead, which is introduced by this commit.

Signed-off-by: Luiz Capitulino <>

12d4536f 09/02/2011 06:34 pm Anthony Liguori

main: force enabling of I/O thread

Enabling the I/O thread by default seems like an important part of declaring
1.0. Besides allowing true SMP support with KVM, the I/O thread means that the
TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which...

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

691a0c9c 07/23/2011 07:26 pm Jan Kiszka

qemu-timer: Introduce clock reset notifier

QEMU_CLOCK_HOST is based on the system time which may jump backward in
case the admin or NTP adjusts it. RTC emulations and other device models
can suffer in this case as timers will stall for the period the clock...

d25f89c9 07/23/2011 07:26 pm Jan Kiszka

Register Linux dyntick timer as per-thread signal

Derived from kvm-tool patch
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309

Ingo Molnar pointed out that sending the timer signal to the whole
process, just blocking it everywhere, is suboptimal with an increasing...

84682834 07/23/2011 07:18 pm Paolo Bonzini

qemu-timer: change unix timer to dynticks

A timer that wakes up every millisecond puts a lot of stress on the
iothread. The large amount of IPIs causes very high context switch
activity, making emulation slow and the UI unusable. This is by the
way the same reason why the Windows timers were switched to dynticks....

25f3151e 06/06/2011 04:54 pm Anthony Liguori

timer: drop HPET and RTC

dynticks will provide equally good timer granularity on all modern Linux
systems. This is more or less dead code these days.

Signed-off-by: Anthony Liguori <>

45c7b37f 04/27/2011 02:30 pm Stefan Weil

qemu-timer: Add and use new function qemu_timer_expired_ns

This simply moves code which is used three times
into a new function thus improving readability.

Signed-off-by: Stefan Weil <>

cd0544ee 04/27/2011 02:30 pm Stefan Weil

qemu-timer: Avoid type casts

The type casts are no longer needed after some small changes
in struct qemu_alarm_timer. This also improves readability
of the code.

Signed-off-by: Stefan Weil <>

2f9cba0c 04/27/2011 02:30 pm Stefan Weil

qemu-timer: Fix timers for w32

Commit 68c23e5520e8286d79d96ab47c0ea722ceb75041 removed the
multimedia timer, but this timer is needed for certain
Linux kernels. Otherwise Linux boot stops with this error:

MP-BIOS bug: 8254 timer not connected to IO-APIC...
ab33fcda 04/15/2011 10:27 am Paolo Bonzini

enable vm_clock to "warp" in the iothread+icount case

The previous patch however is not enough, because if the virtual CPU
goes to sleep waiting for a future timer interrupt to wake it up, qemu
deadlocks. The timer interrupt never comes because time is driven by...

1ece93a9 04/15/2011 10:27 am Paolo Bonzini

Revert wrong fixes for -icount in the iothread case

This reverts commits 225d02cd and c9f7383c. While some parts of
the latter could be saved, I preferred a smooth, complete revert.

Signed-off-by: Paolo Bonzini <>
Tested-by: Edgar E. Iglesias <>...

cb842c90 04/15/2011 10:27 am Paolo Bonzini

qemu_next_deadline should not consider host-time timers

It is purely for icount-based virtual timers. And now that we got the
code right, rename the function to clarify the intended scope.

Signed-off-by: Paolo Bonzini <>
Tested-by: Edgar E. Iglesias <>...

7bd427d8 03/21/2011 10:23 am Paolo Bonzini

change all rt_clock references to use millisecond resolution accessors

This was done with:

sed -i '/get_clock\>.*rt_clock/s/get_clock\>/get_clock_ms/' \
$(git grep -l 'get_clock\>.*rt_clock' )
sed -i '/new_timer\>.*rt_clock/s/new_timer\>/new_timer_ms/' \...
74475455 03/21/2011 10:23 am Paolo Bonzini

change all other clock references to use nanosecond resolution accessors

This was done with:

sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \
$(git grep -l 'qemu_get_clock\>' )
sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \
$(git grep -l 'qemu_new_timer\>' )...
4a998740 03/21/2011 10:23 am Paolo Bonzini

add a generic scaling mechanism for timers

This enables rt_clock timers to use nanosecond resolution, just by
using the _ns functions; there is really no reason to forbid that.

Migrated timers are all using vm_clock (of course; but I checked that
anyway) so the timers in the savevm files are already in nanosecond...

6d5ad9bf 03/21/2011 10:23 am Paolo Bonzini

remove qemu_get_clock

These patches are already not doing a great service to out-of-tree
modifications to QEMU. However, at least we can warn them by getting
rid of the old confusing functions, or otherwise causing compilation
errors. This patch removes qemu_get_clock; the previous one changed...

cfced5b2 03/13/2011 04:44 pm Paolo Bonzini

implement win32 dynticks timer

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

68c23e55 03/13/2011 04:44 pm Paolo Bonzini

use win32 timer queues

Multimedia timers are only useful for compatibility with Windows NT 4.0
and earlier. Plus, the implementation in Wine is extremely heavyweight.

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

c9f7383c 02/23/2011 11:42 am Paolo Bonzini

do not use qemu_icount_delta in the !use_icount case

The !use_icount code is the same for iothread and non-iothread,
except that the timeout is different. Since the timeout might as
well be infinite and is only masking bugs, use the higher value.
With this change the !use_icount code is handled equivalently...

f26e5a54 02/07/2011 09:50 pm Stefan Weil

qemu-timer: Fix compilation of new timer code for w32, w64

qemu_next_alarm_deadline() is needed by MinGW, too.

Cc: Paolo Bonzini <>
Cc: Anthony Liguori <>
Acked-by: Paolo Bonzini <>
Signed-off-by: Stefan Weil <>...

9c13246a 02/04/2011 02:33 pm Paolo Bonzini

use nanoseconds everywhere for timeout computation

Suggested by Aurelien Jarno.

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

6ad0a1ed 02/04/2011 02:33 pm Paolo Bonzini

Correct alarm deadline computation

When the QEMU_CLOCK_HOST clock was added, computation of its
deadline was added to qemu_next_deadline, which is correct but
incomplete.

I noticed this by reading the very convoluted rules whereby
qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST...

4c3d45eb 02/04/2011 02:33 pm Paolo Bonzini

Unify alarm deadline computation

This patch shows how using the correct formula for
qemu_next_deadline_dyntick can simplify the code of
host_alarm_handler and eliminate useless duplication.

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

225d02cd 01/23/2011 05:44 am Edgar E. Iglesias

Avoid deadlock whith iothread and icount

When using the iothread together with icount, make sure the
qemu_icount counter makes forward progress when the vcpu is
idle to avoid deadlocks.

Signed-off-by: Edgar E. Iglesias <>

c57c846a 10/23/2010 06:24 pm Blue Swirl

qemu-timer: move commonly used timer code to qemu-timer-common

Move timer init functions to a new file, qemu-timer-common.c. Make other
critical timer functions inlined to preserve performance in
qemu-timer.c, also move muldiv64() (used by the inline functions)...

0be71e32 07/06/2010 06:36 pm Alex Williamson

savevm: Add DeviceState param

When available, we'd like to be able to access the DeviceState
when registering a savevm. For buses with a get_dev_path()
function, this will allow us to create more unique savevm
id strings.

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

29e922b6 03/29/2010 10:24 pm Blue Swirl

Compile qemu-timer only once

Arrange various declarations so that also non-CPU code can access
them, adjust users.

Move CPU specific code to cpus.c.

Signed-off-by: Blue Swirl <>

44459349 03/27/2010 03:38 pm Juergen Lock

Add a missing #include for FreeBSD hosts

Signed-off-by: Juergen Lock <>
Signed-off-by: Aurelien Jarno <>

ca5a2a4b 03/27/2010 03:05 pm Paolo Bonzini

fix race between timer firing vs. alarm_timer->pending = 0

The period for Win32 timers is very short and always the same
independent of dynticks, so it's possible that the timer fires
before qemu_run_all_timers has reset alarm_timer->pending to zero.
Reset alarm_timer->pending before rearming....

db1a4972 03/17/2010 06:16 pm Paolo Bonzini

split out qemu-timer.c

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