aboutsummaryrefslogtreecommitdiff
path: root/qemu-timer.c
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@gmail.com>2011-01-23 04:44:51 +0100
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>2011-01-23 04:44:51 +0100
commit225d02cd1a34d5d87e8acefbf8e244a5d12f5f8c (patch)
tree3aec7dbb5cc7d6333bcbcb015b9c3846b9749aac /qemu-timer.c
parent5d0bb8239d84292380d0024acd0d510cc957dae0 (diff)
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 <edgar.iglesias@gmail.com>
Diffstat (limited to 'qemu-timer.c')
-rw-r--r--qemu-timer.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/qemu-timer.c b/qemu-timer.c
index 95814af798..db1ec49b3f 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -110,7 +110,6 @@ static int64_t cpu_get_clock(void)
}
}
-#ifndef CONFIG_IOTHREAD
static int64_t qemu_icount_delta(void)
{
if (!use_icount) {
@@ -124,7 +123,6 @@ static int64_t qemu_icount_delta(void)
return cpu_get_icount() - cpu_get_clock();
}
}
-#endif
/* enable cpu_get_ticks() */
void cpu_enable_ticks(void)
@@ -1077,9 +1075,17 @@ void quit_timers(void)
int qemu_calculate_timeout(void)
{
-#ifndef CONFIG_IOTHREAD
int timeout;
+#ifdef CONFIG_IOTHREAD
+ /* When using icount, making forward progress with qemu_icount when the
+ guest CPU is idle is critical. We only use the static io-thread timeout
+ for non icount runs. */
+ if (!use_icount) {
+ return 1000;
+ }
+#endif
+
if (!vm_running)
timeout = 5000;
else {
@@ -1110,8 +1116,5 @@ int qemu_calculate_timeout(void)
}
return timeout;
-#else /* CONFIG_IOTHREAD */
- return 1000;
-#endif
}