summaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2010-01-26 10:31:46 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-02-09 16:56:13 -0600
commit41c872b6bf010a3033f3032cd41db6cab14173e6 (patch)
tree0de93043112e3128c1117affccc2b451abdae73f /vl.c
parente970ec0b5e26d9f605f57e80818866baa6e769db (diff)
downloadhqemu-41c872b6bf010a3033f3032cd41db6cab14173e6.zip
hqemu-41c872b6bf010a3033f3032cd41db6cab14173e6.tar.gz
add qemu_get_clock_ns
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 <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/vl.c b/vl.c
index 880bcd5..b87044c 100644
--- a/vl.c
+++ b/vl.c
@@ -931,6 +931,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();
@@ -2866,7 +2883,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;
@@ -2877,7 +2894,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
OpenPOWER on IntegriCloud