fix for hosts resuming from software suspend (initial patch by John Coiner)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1884 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
07de1eaa9d
commit
eade0f192e
11
vl.c
11
vl.c
@ -558,6 +558,7 @@ int64_t cpu_get_real_ticks(void)
|
|||||||
#error unsupported CPU
|
#error unsupported CPU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int64_t cpu_ticks_prev;
|
||||||
static int64_t cpu_ticks_offset;
|
static int64_t cpu_ticks_offset;
|
||||||
static int cpu_ticks_enabled;
|
static int cpu_ticks_enabled;
|
||||||
|
|
||||||
@ -566,7 +567,15 @@ static inline int64_t cpu_get_ticks(void)
|
|||||||
if (!cpu_ticks_enabled) {
|
if (!cpu_ticks_enabled) {
|
||||||
return cpu_ticks_offset;
|
return cpu_ticks_offset;
|
||||||
} else {
|
} else {
|
||||||
return cpu_get_real_ticks() + cpu_ticks_offset;
|
int64_t ticks;
|
||||||
|
ticks = cpu_get_real_ticks();
|
||||||
|
if (cpu_ticks_prev > ticks) {
|
||||||
|
/* Note: non increasing ticks may happen if the host uses
|
||||||
|
software suspend */
|
||||||
|
cpu_ticks_offset += cpu_ticks_prev - ticks;
|
||||||
|
}
|
||||||
|
cpu_ticks_prev = ticks;
|
||||||
|
return ticks + cpu_ticks_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user