Received: from [140.186.70.92] (port=41210 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkzYm-0003rK-U8 for qemu-devel@nongnu.org; Thu, 03 Feb 2011 08:49:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PkzYg-0004FW-7O for qemu-devel@nongnu.org; Thu, 03 Feb 2011 08:49:16 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:59822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PkzYg-0004Ci-3T for qemu-devel@nongnu.org; Thu, 03 Feb 2011 08:49:14 -0500 Received: by mail-gy0-f173.google.com with SMTP id 5so529094gye.4 for ; Thu, 03 Feb 2011 05:49:13 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 3 Feb 2011 14:49:00 +0100 Message-Id: <1296740941-24296-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1296740941-24296-1-git-send-email-pbonzini@redhat.com> References: <1296740941-24296-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/3] Correct alarm deadline computation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jan Kiszka , aurelien@aurel32.net When the QEMU_CLOCK_HOST clock was added, computation of its deadline was added to qemu_next_deadline, which is correct but incomplete. I noticed this by reading the very convoluted rules whereby qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST when use_icount is true. This patch inlines qemu_next_deadline into qemu_next_deadline_dyntick, and then corrects the logic to skip only QEMU_CLOCK_VIRTUAL when use_icount is true. Signed-off-by: Paolo Bonzini Cc: Jan Kiszka --- qemu-timer.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 60283a8..c19d0a2 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -724,11 +724,18 @@ static uint64_t qemu_next_deadline_dyntick(void) int64_t delta; int64_t rtdelta; - if (use_icount) + if (!use_icount && active_timers[QEMU_CLOCK_VIRTUAL]) { + delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time - + qemu_get_clock(vm_clock); + } else { delta = INT32_MAX; - else - delta = qemu_next_deadline(); - + } + if (active_timers[QEMU_CLOCK_HOST]) { + int64_t hdelta = active_timers[QEMU_CLOCK_HOST]->expire_time - + qemu_get_clock_ns(host_clock); + if (hdelta < delta) + delta = hdelta; + } if (active_timers[QEMU_CLOCK_REALTIME]) { rtdelta = (active_timers[QEMU_CLOCK_REALTIME]->expire_time * 1000000 - qemu_get_clock_ns(rt_clock)); -- 1.7.3.4