qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Ed Swierk" <eswierk@arastra.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix qemu hang when i386 Linux host resumes from suspend
Date: Sun, 30 Apr 2006 20:24:10 -0700	[thread overview]
Message-ID: <c1bf1cf0604302024h38a1df9evf765bb127f25b47e@mail.gmail.com> (raw)

[-- 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;
     }
 }

                 reply	other threads:[~2006-05-01  3:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1bf1cf0604302024h38a1df9evf765bb127f25b47e@mail.gmail.com \
    --to=eswierk@arastra.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).