summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlauber Costa <glommer@redhat.com>2009-10-16 15:27:39 -0400
committerMarcelo Tosatti <mtosatti@redhat.com>2009-10-19 17:49:16 -0200
commit79529cd01512d998246e8e24714ef5a7526603a0 (patch)
tree5516730e29966783dfa67702aa3fe9e9526ca242 /qemu-kvm-x86.c
parentproperly save kvm system time msr registers (diff)
downloadqemu-kvm-79529cd01512d998246e8e24714ef5a7526603a0.tar.gz
qemu-kvm-79529cd01512d998246e8e24714ef5a7526603a0.tar.bz2
qemu-kvm-79529cd01512d998246e8e24714ef5a7526603a0.zip
get and set clock upon migration
Register a vmstate handler for kvmclock. The goal here is to pass information about current time to migration, so we avoid going backwards or jumping too much. We use our plain new ioctls for that. Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'qemu-kvm-x86.c')
-rw-r--r--qemu-kvm-x86.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index aa123defb..fb70edeb5 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -767,6 +767,37 @@ int kvm_qemu_destroy_memory_alias(uint64_t phys_start)
return kvm_destroy_memory_alias(kvm_context, phys_start);
}
+#ifdef KVM_CAP_ADJUST_CLOCK
+static struct kvm_clock_data kvmclock_data;
+
+static void kvmclock_pre_save(void *opaque)
+{
+ struct kvm_clock_data *cl = opaque;
+
+ kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, cl);
+}
+
+static int kvmclock_post_load(void *opaque, int version_id)
+{
+ struct kvm_clock_data *cl = opaque;
+
+ return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, cl);
+}
+
+static const VMStateDescription vmstate_kvmclock= {
+ .name = "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),
+ VMSTATE_END_OF_LIST()
+ }
+};
+#endif
+
int kvm_arch_qemu_create_context(void)
{
int i;
@@ -788,6 +819,10 @@ int kvm_arch_qemu_create_context(void)
kvm_has_vm_hsave_pa = 1;
}
+#ifdef KVM_CAP_ADJUST_CLOCK
+ if (kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK))
+ vmstate_register(0, &vmstate_kvmclock, &kvmclock_data);
+#endif
return 0;
}