enable vm_clock to "warp" in the iothread+icount case
commitab33fcda9f96b9195dfb3fcf5bd9bb5383caeaea
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 13 Apr 2011 08:03:44 +0000 (13 10:03 +0200)
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>
Fri, 15 Apr 2011 07:27:56 +0000 (15 09:27 +0200)
tree97a1a32a03b69a15fb4f23f7a5eb5e880d036980
parent3b2319a30b5ae528787bf3769b1a28a863b53252
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
icount, but the vCPU doesn't run any insns.

You could say that VCPUs should never go to sleep in icount
mode if there is a pending vm_clock timer; rather time should
just warp to the next vm_clock event with no sleep ever taking place.
Even better, you can sleep for some time related to the
time left until the next event, to avoid that the warps are too visible
externally; for example, you could be sending network packets continously
instead of every 100ms.

This is what this patch implements.  qemu_clock_warp is called: 1)
whenever a vm_clock timer is adjusted, to ensure the warp_timer is
synchronized; 2) at strategic points in the CPU thread, to make sure
the insn counter is synchronized before the CPU starts running.
In any case, the warp_timer is disabled while the CPU is running,
because the insn counter will then be making progress on its own.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
cpus.c
qemu-common.h
qemu-timer.c
qemu-timer.h