Properly save kvm time registers (#524229)
This commit is contained in:
parent
98f6658c28
commit
690ee5d1c6
119
qemu-properly-save-kvm-system-time-registers.patch
Normal file
119
qemu-properly-save-kvm-system-time-registers.patch
Normal file
@ -0,0 +1,119 @@
|
||||
From 20a3c3095744ea65b4dfb5365efea8cdb802f7f5 Mon Sep 17 00:00:00 2001
|
||||
From: Glauber Costa <glommer@redhat.com>
|
||||
Date: Wed, 21 Oct 2009 10:52:46 -0400
|
||||
Subject: [PATCH] properly save kvm system time msr registers
|
||||
|
||||
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.
|
||||
|
||||
Fedora-patch: qemu-properly-save-kvm-system-time-registers.patch
|
||||
Signed-off-by: Glauber Costa <glommer@redhat.com>
|
||||
---
|
||||
qemu-kvm-x86.c | 15 +++++++++++++--
|
||||
target-i386/cpu.h | 5 ++++-
|
||||
target-i386/machine.c | 8 ++++++++
|
||||
3 files changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
|
||||
index d5436b6..300e6c2 100644
|
||||
--- a/qemu-kvm-x86.c
|
||||
+++ b/qemu-kvm-x86.c
|
||||
@@ -839,6 +839,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;
|
||||
@@ -847,9 +853,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)
|
||||
@@ -1007,6 +1013,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)
|
||||
@@ -1184,6 +1192,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 08200ed..22e76ec 100644
|
||||
--- a/target-i386/cpu.h
|
||||
+++ b/target-i386/cpu.h
|
||||
@@ -640,6 +640,9 @@ typedef struct CPUX86State {
|
||||
target_ulong fmask;
|
||||
target_ulong kernelgsbase;
|
||||
#endif
|
||||
+ uint64_t system_time_msr;
|
||||
+ uint64_t wall_clock_msr;
|
||||
+
|
||||
|
||||
uint64_t tsc;
|
||||
|
||||
@@ -867,7 +870,7 @@ static inline int cpu_get_time_fast(void)
|
||||
#define cpu_signal_handler cpu_x86_signal_handler
|
||||
#define cpu_list x86_cpu_list
|
||||
|
||||
-#define CPU_SAVE_VERSION 10
|
||||
+#define CPU_SAVE_VERSION 11
|
||||
|
||||
/* MMU modes definitions */
|
||||
#define MMU_MODE0_SUFFIX _kernel
|
||||
diff --git a/target-i386/machine.c b/target-i386/machine.c
|
||||
index ca32a92..4654508 100644
|
||||
--- a/target-i386/machine.c
|
||||
+++ b/target-i386/machine.c
|
||||
@@ -174,6 +174,9 @@ void cpu_save(QEMUFile *f, void *opaque)
|
||||
qemu_put_be64s(f, &env->mce_banks[4*i + 3]);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ qemu_put_be64s(f, &env->system_time_msr);
|
||||
+ qemu_put_be64s(f, &env->wall_clock_msr);
|
||||
}
|
||||
|
||||
#ifdef USE_X86LDOUBLE
|
||||
@@ -405,5 +408,10 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
|
||||
kvm_arch_load_mpstate(env);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ if (version_id >= 11) {
|
||||
+ qemu_get_be64s(f, &env->system_time_msr);
|
||||
+ qemu_get_be64s(f, &env->wall_clock_msr);
|
||||
+ }
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
1.6.2.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: QEMU is a FAST! processor emulator
|
||||
Name: qemu
|
||||
Version: 0.11.0
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
# Epoch because we pushed a qemu-1.0 package
|
||||
Epoch: 2
|
||||
License: GPLv2+ and LGPLv2+ and BSD
|
||||
@ -52,6 +52,9 @@ Patch09: qemu-fix-qcow2-backing-file-with-virtio.patch
|
||||
# Fix potential segfault from too small MSR_COUNT (#528901)
|
||||
Patch10: qemu-fix-msr-count-potential-segfault.patch
|
||||
|
||||
# Properly save kvm time registers (#524229)
|
||||
Patch11: qemu-properly-save-kvm-system-time-registers.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: SDL-devel zlib-devel which texi2html gnutls-devel cyrus-sasl-devel
|
||||
BuildRequires: rsync dev86 iasl
|
||||
@ -249,6 +252,7 @@ such as kvmtrace and kvm_stat.
|
||||
%patch08 -p1
|
||||
%patch09 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
|
||||
%build
|
||||
# --build-id option is used fedora 8 onwards for giving info to the debug packages.
|
||||
@ -530,6 +534,9 @@ fi
|
||||
%{_mandir}/man1/qemu-img.1*
|
||||
|
||||
%changelog
|
||||
* Wed Oct 21 2009 Glauber Costa <gcosta@redhat.com> - 2:0.11.0-8
|
||||
- Properly save kvm time registers (#524229)
|
||||
|
||||
* Mon Oct 19 2009 Mark McLoughlin <markmc@redhat.com> - 2:0.11.0-7
|
||||
- Fix potential segfault from too small MSR_COUNT (#528901)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user