[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v3 3/3] target-i386: load the migrated vcpu's TSC rate
From: |
Haozhong Zhang |
Subject: |
[Qemu-ppc] [PATCH v3 3/3] target-i386: load the migrated vcpu's TSC rate |
Date: |
Mon, 2 Nov 2015 17:26:43 +0800 |
Set vcpu's TSC rate to the migrated value if the user does not specify a
TSC rate by cpu option 'tsc-freq' and a migrated TSC rate does exist. If
KVM supports TSC scaling, guest programs will observe TSC increasing in
the migrated rate other than the host TSC rate.
Signed-off-by: Haozhong Zhang <address@hidden>
---
target-i386/kvm.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index aae5e58..2be70df 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -3042,6 +3042,27 @@ int kvm_arch_setup_tsc_khz(CPUState *cs)
int r;
/*
+ * If a TSC rate is migrated and the user does not specify the
+ * vcpu's TSC rate on the destination, the migrated TSC rate will
+ * be used on the destination after the migration.
+ */
+ if (env->tsc_khz_saved && !env->tsc_khz) {
+ if (kvm_check_extension(cs->kvm_state, KVM_CAP_TSC_CONTROL)) {
+ r = kvm_vcpu_ioctl(cs, KVM_SET_TSC_KHZ, env->tsc_khz_saved);
+ if (r < 0) {
+ fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
+ }
+ } else {
+ r = -1;
+ fprintf(stderr, "KVM doesn't support TSC scaling\n");
+ }
+ if (r < 0) {
+ fprintf(stderr, "Use host TSC frequency instead. "
+ "Guest TSC may be inaccurate.\n");
+ }
+ }
+
+ /*
* Prepare vcpu's TSC rate to be migrated.
*
* - If the user specifies the TSC rate by cpu option 'tsc-freq',
--
2.4.8
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, (continued)
[Qemu-ppc] [PATCH v3 1/3] target-i386: add a subsection for migrating vcpu's TSC rate, Haozhong Zhang, 2015/11/02
[Qemu-ppc] [PATCH v3 3/3] target-i386: load the migrated vcpu's TSC rate,
Haozhong Zhang <=