From patchwork Mon Dec 21 08:09:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 41524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E4C2CB6F0E for ; Mon, 21 Dec 2009 19:44:27 +1100 (EST) Received: from localhost ([127.0.0.1]:39059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMdsO-0004Y4-RX for incoming@patchwork.ozlabs.org; Mon, 21 Dec 2009 03:44:24 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMdKs-0002jo-JX for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMdKm-0002hH-Ia for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:44 -0500 Received: from [199.232.76.173] (port=52816 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMdKm-0002hC-2E for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61300) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMdKl-0003oO-Iu for qemu-devel@nongnu.org; Mon, 21 Dec 2009 03:09:39 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89cCU012576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Dec 2009 03:09:39 -0500 Received: from localhost.localdomain (vpn2-10-119.ams2.redhat.com [10.36.10.119]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBL89V3R011460 for ; Mon, 21 Dec 2009 03:09:38 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 21 Dec 2009 09:09:18 +0100 Message-Id: <1261382970-23251-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> References: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 07/19] add qemu_get_clock_ns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Some places use get_clock directly because they want to access the rt_clock with nanosecond precision. Add a function to do exactly that instead of using internal interfaces. Signed-off-by: Paolo Bonzini --- qemu-timer.h | 1 + vl.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/qemu-timer.h b/qemu-timer.h index e7eaa04..c17b4e6 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -25,6 +25,7 @@ extern QEMUClock *vm_clock; extern QEMUClock *host_clock; int64_t qemu_get_clock(QEMUClock *clock); +int64_t qemu_get_clock_ns(QEMUClock *clock); QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque); void qemu_free_timer(QEMUTimer *ts); diff --git a/vl.c b/vl.c index 1af2f81..797c56f 100644 --- a/vl.c +++ b/vl.c @@ -1144,6 +1144,23 @@ int64_t qemu_get_clock(QEMUClock *clock) } } +int64_t qemu_get_clock_ns(QEMUClock *clock) +{ + switch(clock->type) { + case QEMU_CLOCK_REALTIME: + return get_clock(); + default: + case QEMU_CLOCK_VIRTUAL: + if (use_icount) { + return cpu_get_icount(); + } else { + return cpu_get_clock(); + } + case QEMU_CLOCK_HOST: + return get_clock_realtime(); + } +} + static void init_clocks(void) { init_get_clock(); @@ -3094,7 +3111,7 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) } bytes_transferred_last = bytes_transferred; - bwidth = get_clock(); + bwidth = qemu_get_clock_ns(rt_clock); while (!qemu_file_rate_limit(f)) { int ret; @@ -3105,7 +3122,7 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) break; } - bwidth = get_clock() - bwidth; + bwidth = qemu_get_clock_ns(rt_clock) - bwidth; bwidth = (bytes_transferred - bytes_transferred_last) / bwidth; /* if we haven't transferred anything this round, force expected_time to a