[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common C
From: |
Zhu Guihua |
Subject: |
[Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common CPUClass.realizefn |
Date: |
Fri, 13 Feb 2015 18:25:28 +0800 |
From: Gu Zheng <address@hidden>
Move cpu vmstate register from cpu_exec_init into cpu_common_realizefn,
and use cc->get_arch_id as the instance id that suggested by Igor to
fix the migration issue.
Signed-off-by: Gu Zheng <address@hidden>
Signed-off-by: Zhu Guihua <address@hidden>
---
exec.c | 25 ++++++++++++++++++-------
include/qom/cpu.h | 2 ++
qom/cpu.c | 4 ++++
3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/exec.c b/exec.c
index 6dff7bc..8361591 100644
--- a/exec.c
+++ b/exec.c
@@ -513,10 +513,26 @@ void tcg_cpu_address_space_init(CPUState *cpu,
AddressSpace *as)
}
#endif
+void cpu_vmstate_register(CPUState *cpu)
+{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
+ int cpu_index = cc->get_arch_id(cpu) + max_cpus;
+ int compat_index = cc->get_compat_arch_id(cpu);
+
+ if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
+ vmstate_register_with_alias_id(NULL, cpu_index, &vmstate_cpu_common,
+ cpu, compat_index, 3);
+ }
+
+ if (cc->vmsd != NULL) {
+ vmstate_register_with_alias_id(NULL, cpu_index, cc->vmsd,
+ cpu, compat_index, 3);
+ }
+}
+
void cpu_exec_init(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
- CPUClass *cc = CPU_GET_CLASS(cpu);
CPUState *some_cpu;
int cpu_index;
@@ -539,18 +555,13 @@ void cpu_exec_init(CPUArchState *env)
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif
- if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
- vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu);
- }
#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
+ CPUClass *cc = CPU_GET_CLASS(cpu);
register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
cpu_save, cpu_load, env);
assert(cc->vmsd == NULL);
assert(qdev_get_vmsd(DEVICE(cpu)) == NULL);
#endif
- if (cc->vmsd != NULL) {
- vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
- }
}
#if defined(CONFIG_USER_ONLY)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 2e68dd2..d0a50e2 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -565,6 +565,8 @@ void cpu_interrupt(CPUState *cpu, int mask);
#endif /* USER_ONLY */
+void cpu_vmstate_register(CPUState *cpu);
+
#ifdef CONFIG_SOFTMMU
static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
bool is_write, bool is_exec,
diff --git a/qom/cpu.c b/qom/cpu.c
index 83d7766..8e37045 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -302,6 +302,10 @@ static void cpu_common_realizefn(DeviceState *dev, Error
**errp)
{
CPUState *cpu = CPU(dev);
+#if !defined(CONFIG_USER_ONLY)
+ cpu_vmstate_register(cpu);
+#endif
+
if (dev->hotplugged) {
cpu_synchronize_post_init(cpu);
cpu_resume(cpu);
--
1.9.3
- [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 01/10] cpu/apic: drop icc bus/bridge/, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 03/10] cpu: introduce CpuTopoInfo structure for argument simplification, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 02/10] icc_bus: remove icc related files, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 06/10] qom/cpu: move apic vmstate register into x86_cpu_apic_realize, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 04/10] cpu: introduce get_compat_arch_id() method and override it for X86CPU, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common CPUClass.realizefn,
Zhu Guihua <=
- [Qemu-devel] [PATCH v4 07/10] monitor: use cc->get_arch_id as the cpu index, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 08/10] acpi: introduce acpi_send_gpe_event(), Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 09/10] cpu: add device_add foo-x86_64-cpu support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 10/10] i386/cpu: add instance finalize callback, Zhu Guihua, 2015/02/13
- Re: [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support, Gu Zheng, 2015/02/23
- Re: [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support, Bharata B Rao, 2015/02/25