From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZgrM-0003KR-10 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:17 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZgrE-0003Gv-8G for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:13 -0500 Received: from [199.232.76.173] (port=50315 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZgrA-0003GQ-NM for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:05 -0500 Received: from mx20.gnu.org ([199.232.41.8]:43114) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NZgr9-0008JU-Vg for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:04 -0500 Received: from mtagate4.uk.ibm.com ([194.196.100.164]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZgr8-0003dT-7b for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:02 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o0Q8WxNi011856 for ; Tue, 26 Jan 2010 08:32:59 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0Q8WxDV1581182 for ; Tue, 26 Jan 2010 08:32:59 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o0Q8Wx4F012289 for ; Tue, 26 Jan 2010 08:32:59 GMT From: Liran Schour Date: Tue, 26 Jan 2010 10:31:46 +0200 Message-Id: <1264494709-31848-3-git-send-email-lirans@il.ibm.com> In-Reply-To: <1264494709-31848-2-git-send-email-lirans@il.ibm.com> References: <1264494709-31848-1-git-send-email-lirans@il.ibm.com> <1264494709-31848-2-git-send-email-lirans@il.ibm.com> Subject: [Qemu-devel] [PATCH v3 2/5] add qemu_get_clock_ns List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini From: Paolo Bonzini 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 e881e45..c5cd462 100644 --- a/vl.c +++ b/vl.c @@ -1131,6 +1131,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(); @@ -3063,7 +3080,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; @@ -3074,7 +3091,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 -- 1.6.0.4