* [Qemu-devel] [PATCH] Fix qemu hang when i386 Linux host resumes from suspend
@ 2006-05-01 3:24 Ed Swierk
0 siblings, 0 replies; only message in thread
From: Ed Swierk @ 2006-05-01 3:24 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 320 bytes --]
qemu hangs when an i386 Linux host resumes from suspend (swsusp2),
because the host's TSC is reset to a value lower than it was before
the suspend.
Although this is a bug in the host OS, the attached patch (originally
from John Coiner) is simple and makes qemu more resilient to weird
host tick counter behavior.
--Ed
[-- Attachment #2: qemu-nondecreasing-ticks.patch --]
[-- Type: text/x-patch, Size: 890 bytes --]
diff -BurN qemu-snapshot-2006-03-27_23.orig/vl.c qemu-snapshot-2006-03-27_23/vl.c
--- qemu-snapshot-2006-03-27_23.orig/vl.c 2006-04-01 18:38:27.000000000 +0000
+++ qemu-snapshot-2006-03-27_23/vl.c 2006-04-01 18:41:36.000000000 +0000
@@ -579,14 +579,21 @@
#error unsupported CPU
#endif
-static int64_t cpu_ticks_offset;
-static int cpu_ticks_enabled;
+static int64_t cpu_ticks_prev;
+static int64_t cpu_ticks_offset;
+static int cpu_ticks_enabled;
static inline int64_t cpu_get_ticks(void)
{
if (!cpu_ticks_enabled) {
return cpu_ticks_offset;
} else {
+ int64_t ticks;
+ ticks = cpu_get_real_ticks();
+ if (cpu_ticks_prev > ticks) {
+ cpu_ticks_offset += cpu_ticks_prev - ticks;
+ }
+ cpu_ticks_prev = ticks;
- return cpu_get_real_ticks() + cpu_ticks_offset;
+ return ticks + cpu_ticks_offset;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-01 3:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-01 3:24 [Qemu-devel] [PATCH] Fix qemu hang when i386 Linux host resumes from suspend Ed Swierk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).