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
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; } }
_______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel