@@ -500,11 +500,11 @@ static int kvm_enable_tpr_access_reporting(CPUState *env)
#ifdef KVM_CAP_ADJUST_CLOCK
static struct kvm_clock_data kvmclock_data;
-static void kvmclock_pre_save(void *opaque)
+static void kvmclock_update_clock(void *opaque, int running, int reason)
{
struct kvm_clock_data *cl = opaque;
- if (!kvmclock_enabled)
+ if ((!kvmclock_enabled) || running)
return;
kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, cl);
@@ -522,7 +522,6 @@ static const VMStateDescription vmstate_kvmclock= {
.version_id = 1,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
- .pre_save = kvmclock_pre_save,
.post_load = kvmclock_post_load,
.fields = (VMStateField []) {
VMSTATE_U64(clock, struct kvm_clock_data),
@@ -537,6 +536,7 @@ void kvmclock_register_savevm(void)
#ifdef KVM_CAP_ADJUST_CLOCK
if (kvmclock_enabled && kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK)) {
vmstate_register(NULL, 0, &vmstate_kvmclock, &kvmclock_data);
+ qemu_add_vm_change_state_handler(kvmclock_update_clock, &kvmclock_data);
}
#endif
}