[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 45/73] block: do not use get_clock()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 45/73] block: do not use get_clock() |
Date: |
Wed, 10 Dec 2014 11:34:11 +0100 |
From: Paolo Bonzini <address@hidden>
Use the external qemu-timer API instead.
No one else should be calling cpu_get_clock(), get_clock() and
get_clock_realtime() directly; they are internal functions and they
should be confined to qemu-timer.c and cpus.c (where the icount
implementation resides). All accesses should go through
qemu_clock_get_ns.
Cc: address@hidden
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/accounting.c | 6 ++++--
block/raw-posix.c | 8 ++++----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/block/accounting.c b/block/accounting.c
index edbb1cc..18102f0 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -24,6 +24,7 @@
#include "block/accounting.h"
#include "block/block_int.h"
+#include "qemu/timer.h"
void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie,
int64_t bytes, enum BlockAcctType type)
@@ -31,7 +32,7 @@ void block_acct_start(BlockAcctStats *stats, BlockAcctCookie
*cookie,
assert(type < BLOCK_MAX_IOTYPE);
cookie->bytes = bytes;
- cookie->start_time_ns = get_clock();
+ cookie->start_time_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
cookie->type = type;
}
@@ -41,7 +42,8 @@ void block_acct_done(BlockAcctStats *stats, BlockAcctCookie
*cookie)
stats->nr_bytes[cookie->type] += cookie->bytes;
stats->nr_ops[cookie->type]++;
- stats->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
+ stats->total_time_ns[cookie->type] +=
+ qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - cookie->start_time_ns;
}
diff --git a/block/raw-posix.c b/block/raw-posix.c
index b1af77e..02e107f 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1922,7 +1922,7 @@ static int fd_open(BlockDriverState *bs)
return 0;
last_media_present = (s->fd >= 0);
if (s->fd >= 0 &&
- (get_clock() - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
+ (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >=
FD_OPEN_TIMEOUT) {
qemu_close(s->fd);
s->fd = -1;
#ifdef DEBUG_FLOPPY
@@ -1931,7 +1931,7 @@ static int fd_open(BlockDriverState *bs)
}
if (s->fd < 0) {
if (s->fd_got_error &&
- (get_clock() - s->fd_error_time) < FD_OPEN_TIMEOUT) {
+ (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) <
FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY
printf("No floppy (open delayed)\n");
#endif
@@ -1939,7 +1939,7 @@ static int fd_open(BlockDriverState *bs)
}
s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK);
if (s->fd < 0) {
- s->fd_error_time = get_clock();
+ s->fd_error_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
s->fd_got_error = 1;
if (last_media_present)
s->fd_media_changed = 1;
@@ -1954,7 +1954,7 @@ static int fd_open(BlockDriverState *bs)
}
if (!last_media_present)
s->fd_media_changed = 1;
- s->fd_open_time = get_clock();
+ s->fd_open_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
s->fd_got_error = 0;
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PULL 37/73] qemu-iotests: Test writing non-raw image headers to raw image, (continued)
- [Qemu-devel] [PULL 37/73] qemu-iotests: Test writing non-raw image headers to raw image, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 36/73] qemu-iotests: Fix stderr handling in common.qemu, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 35/73] raw: Prohibit dangerous writes for probed images, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 40/73] blockdev: acquire AioContext in QMP 'transaction' actions, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 42/73] qcow2: Fix header extension size check, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 39/73] blockdev: drop unnecessary DriveBackupState field assignment, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 41/73] blockdev: check for BLOCK_OP_TYPE_INTERNAL_SNAPSHOT, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 38/73] blockdev: update outdated qmp_transaction() comments, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 44/73] block: Don't probe for unknown backing file format, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 46/73] qemu-iotests: 060: Filter the real disk size, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 45/73] block: do not use get_clock(),
Kevin Wolf <=
- [Qemu-devel] [PULL 48/73] nvme: 64kB page size fixes, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 47/73] qemu-iotests: 082: Filter the real disk size, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 49/73] ide: Check validity of logical block size, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 52/73] block: Omit bdrv_find_format for essential drivers, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 50/73] iotests: Specify qcow2 format for qemu-io in 059, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 51/73] block: Make essential BlockDriver objects public, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 53/73] block/vvfat: qcow driver may not be found, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 54/73] block/nfs: Add create_opts, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 56/73] qemu-img: Check create_opts before image creation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 57/73] qemu-img: Check create_opts before image amendment, Kevin Wolf, 2014/12/10