[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 57/69] replay: save prior value of the host clock
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 57/69] replay: save prior value of the host clock |
Date: |
Tue, 13 Mar 2018 23:47:07 +0100 |
From: Pavel Dovgalyuk <address@hidden>
This patch adds saving/restoring of the host clock field 'last'.
It is used in host clock calculation and therefore clock may
become incorrect when using restored vmstate.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
include/qemu/timer.h | 14 ++++++++++++++
replay/replay-internal.h | 2 ++
replay/replay-snapshot.c | 3 +++
util/qemu-timer.c | 12 ++++++++++++
4 files changed, 31 insertions(+)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 3b5a54b014..39ea907e65 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -251,6 +251,20 @@ bool qemu_clock_run_timers(QEMUClockType type);
*/
bool qemu_clock_run_all_timers(void);
+/**
+ * qemu_clock_get_last:
+ *
+ * Returns last clock query time.
+ */
+uint64_t qemu_clock_get_last(QEMUClockType type);
+/**
+ * qemu_clock_set_last:
+ *
+ * Sets last clock query time.
+ */
+void qemu_clock_set_last(QEMUClockType type, uint64_t last);
+
+
/*
* QEMUTimerList
*/
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 3ebb19912a..be96d7e879 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -78,6 +78,8 @@ typedef struct ReplayState {
This counter is global, because requests from different
block devices should not get overlapping ids. */
uint64_t block_request_id;
+ /*! Prior value of the host clock */
+ uint64_t host_clock_last;
} ReplayState;
extern ReplayState replay_state;
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
index 7075986ab5..e0b2204765 100644
--- a/replay/replay-snapshot.c
+++ b/replay/replay-snapshot.c
@@ -25,6 +25,7 @@ static int replay_pre_save(void *opaque)
{
ReplayState *state = opaque;
state->file_offset = ftell(replay_file);
+ state->host_clock_last = qemu_clock_get_last(QEMU_CLOCK_HOST);
return 0;
}
@@ -33,6 +34,7 @@ static int replay_post_load(void *opaque, int version_id)
{
ReplayState *state = opaque;
fseek(replay_file, state->file_offset, SEEK_SET);
+ qemu_clock_set_last(QEMU_CLOCK_HOST, state->host_clock_last);
/* If this was a vmstate, saved in recording mode,
we need to initialize replay data fields. */
replay_fetch_data_kind();
@@ -54,6 +56,7 @@ static const VMStateDescription vmstate_replay = {
VMSTATE_UINT32(has_unread_data, ReplayState),
VMSTATE_UINT64(file_offset, ReplayState),
VMSTATE_UINT64(block_request_id, ReplayState),
+ VMSTATE_UINT64(host_clock_last, ReplayState),
VMSTATE_END_OF_LIST()
},
};
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index 82d56507a2..2ed1bf2778 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -622,6 +622,18 @@ int64_t qemu_clock_get_ns(QEMUClockType type)
}
}
+uint64_t qemu_clock_get_last(QEMUClockType type)
+{
+ QEMUClock *clock = qemu_clock_ptr(type);
+ return clock->last;
+}
+
+void qemu_clock_set_last(QEMUClockType type, uint64_t last)
+{
+ QEMUClock *clock = qemu_clock_ptr(type);
+ clock->last = last;
+}
+
void qemu_clock_register_reset_notifier(QEMUClockType type,
Notifier *notifier)
{
--
2.14.3
- [Qemu-devel] [PULL 45/69] hw/isa/vt82c686: Add the TYPE_VT82C686B_SUPERIO, (continued)
- [Qemu-devel] [PULL 45/69] hw/isa/vt82c686: Add the TYPE_VT82C686B_SUPERIO, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 44/69] hw/isa/vt82c686: Rename vt82c686b_init() -> vt82c686b_isa_init(), Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 43/69] hw/mips/mips_fulong2e: Factor out vt82c686b_southbridge_init(), Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 51/69] hw/i386/pc: Factor out the superio code, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 50/69] hw/alpha/dp264: Use the TYPE_SMC37C669_SUPERIO, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 52/69] cpu-exec: fix exception_index handling, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 53/69] replay: fix processing async events, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 54/69] replay: fixed replay_enable_events, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 56/69] replay: added replay log format description, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 55/69] replay: fix save/load vm for non-empty queue, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 57/69] replay: save prior value of the host clock,
Paolo Bonzini <=
- [Qemu-devel] [PULL 60/69] replay: make locking visible outside replay code, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 59/69] replay/replay-internal.c: track holding of replay_lock, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 58/69] replay/replay.c: bump REPLAY_VERSION again, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 61/69] replay: don't destroy mutex at exit, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 62/69] replay: push replay_mutex_lock up the call tree, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 64/69] replay: avoid recursive call of checkpoints, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 63/69] replay: check return values of fwrite, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 65/69] scripts/replay-dump.py: replay log dumper, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 66/69] replay: don't process async events when warping the clock, Paolo Bonzini, 2018/03/13
- [Qemu-devel] [PULL 67/69] replay: save vmstate of the asynchronous events, Paolo Bonzini, 2018/03/13