From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com
Subject: [PATCH 2/3] properly save kvm system time msr registers
Date: Fri, 16 Oct 2009 15:27:38 -0400 [thread overview]
Message-ID: <1255721259-11740-3-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1255721259-11740-2-git-send-email-glommer@redhat.com>
Currently, the msrs involved in setting up pvclock are not saved over
migration and/or save/restore. This patch puts their value in special
fields in our CPUState, and deal with them using vmstate.
kvm also has to account for it, by including them in the msr list
for the ioctls.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
qemu-kvm-x86.c | 15 +++++++++++++--
target-i386/cpu.h | 4 +++-
target-i386/machine.c | 3 +++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 475151d..693f5b2 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -834,6 +834,12 @@ static int get_msr_entry(struct kvm_msr_entry *entry, CPUState *env)
case MSR_VM_HSAVE_PA:
env->vm_hsave = entry->data;
break;
+ case MSR_KVM_SYSTEM_TIME:
+ env->system_time_msr = entry->data;
+ break;
+ case MSR_KVM_WALL_CLOCK:
+ env->wall_clock_msr = entry->data;
+ break;
default:
printf("Warning unknown msr index 0x%x\n", entry->index);
return 1;
@@ -842,9 +848,9 @@ static int get_msr_entry(struct kvm_msr_entry *entry, CPUState *env)
}
#ifdef TARGET_X86_64
-#define MSR_COUNT 10
+#define MSR_COUNT 12
#else
-#define MSR_COUNT 6
+#define MSR_COUNT 8
#endif
static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs)
@@ -1002,6 +1008,8 @@ void kvm_arch_load_regs(CPUState *env)
set_msr_entry(&msrs[n++], MSR_LSTAR , env->lstar);
}
#endif
+ set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr);
+ set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
rc = kvm_set_msrs(env->kvm_cpu_state.vcpu_ctx, msrs, n);
if (rc == -1)
@@ -1181,6 +1189,9 @@ void kvm_arch_save_regs(CPUState *env)
msrs[n++].index = MSR_LSTAR;
}
#endif
+ msrs[n++].index = MSR_KVM_SYSTEM_TIME;
+ msrs[n++].index = MSR_KVM_WALL_CLOCK;
+
rc = kvm_get_msrs(env->kvm_cpu_state.vcpu_ctx, msrs, n);
if (rc == -1) {
perror("kvm_get_msrs FAILED");
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 278d3e3..4605fd2 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -667,6 +667,8 @@ typedef struct CPUX86State {
target_ulong fmask;
target_ulong kernelgsbase;
#endif
+ uint64_t system_time_msr;
+ uint64_t wall_clock_msr;
uint64_t tsc;
@@ -886,7 +888,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define cpu_signal_handler cpu_x86_signal_handler
#define cpu_list x86_cpu_list
-#define CPU_SAVE_VERSION 11
+#define CPU_SAVE_VERSION 12
/* MMU modes definitions */
#define MMU_MODE0_SUFFIX _kernel
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 16d9c57..b364936 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -479,6 +479,9 @@ const VMStateDescription vmstate_cpu = {
VMSTATE_UINT64_ARRAY_V(mce_banks, CPUState, MCE_BANKS_DEF *4, 10),
/* rdtscp */
VMSTATE_UINT64_V(tsc_aux, CPUState, 11),
+ /* KVM pvclock msr */
+ VMSTATE_UINT64_V(system_time_msr, CPUState, 12),
+ VMSTATE_UINT64_V(wall_clock_msr, CPUState, 12),
VMSTATE_END_OF_LIST()
}
};
--
1.6.2.2
next prev parent reply other threads:[~2009-10-16 19:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-16 19:27 [PATCH 0/3] Fix migration of linux guests using kvmclock Glauber Costa
2009-10-16 19:27 ` [PATCH 1/3] introduce VMSTATE_U64 Glauber Costa
2009-10-16 19:27 ` Glauber Costa [this message]
2009-10-16 19:27 ` [PATCH 3/3] get and set clock upon migration Glauber Costa
2009-10-19 23:40 ` [PATCH 1/3] introduce VMSTATE_U64 Avi Kivity
2009-10-20 0:38 ` Glauber Costa
2009-10-19 19:51 ` [PATCH 0/3] Fix migration of linux guests using kvmclock Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1255721259-11740-3-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox