[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/17] cpu: Register VMStateDescription through CPUS
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 08/17] cpu: Register VMStateDescription through CPUState |
Date: |
Tue, 12 Mar 2013 10:49:09 +0100 |
In comparison to DeviceClass::vmsd, CPU VMState is split in two,
"cpu_common" and "cpu", and uses cpu_index as instance_id instead of -1.
Therefore add a CPU-specific CPUClass::vmsd field.
Unlike the legacy CPUArchState registration, rather register CPUState.
Signed-off-by: Juan Quintela <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
---
exec.c | 11 +++++++++--
include/qom/cpu.h | 3 +++
2 Dateien geändert, 12 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
diff --git a/exec.c b/exec.c
index 0a96ddb..254ae62 100644
--- a/exec.c
+++ b/exec.c
@@ -219,7 +219,7 @@ void cpu_exec_init_all(void)
#endif
}
-#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
static int cpu_common_post_load(void *opaque, int version_id)
{
@@ -245,6 +245,8 @@ static const VMStateDescription vmstate_cpu_common = {
VMSTATE_END_OF_LIST()
}
};
+#else
+#define vmstate_cpu_common vmstate_dummy
#endif
CPUState *qemu_get_cpu(int index)
@@ -266,6 +268,7 @@ CPUState *qemu_get_cpu(int index)
void cpu_exec_init(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
+ CPUClass *cc = CPU_GET_CLASS(cpu);
CPUArchState **penv;
int cpu_index;
@@ -290,11 +293,15 @@ void cpu_exec_init(CPUArchState *env)
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif
-#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
+#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
cpu_save, cpu_load, env);
+ assert(cc->vmsd == NULL);
#endif
+ if (cc->vmsd != NULL) {
+ vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
+ }
}
#if defined(TARGET_HAS_ICE)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index ab2657c..5b1b0d7 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -44,6 +44,7 @@ typedef struct CPUState CPUState;
* @class_by_name: Callback to map -cpu command line model name to an
* instantiatable CPU type.
* @reset: Callback to reset the #CPUState to its initial state.
+ * @vmsd: State description for migration.
*
* Represents a CPU family or model.
*/
@@ -55,6 +56,8 @@ typedef struct CPUClass {
ObjectClass *(*class_by_name)(const char *cpu_model);
void (*reset)(CPUState *cpu);
+
+ const struct VMStateDescription *vmsd;
} CPUClass;
struct KVMState;
--
1.7.10.4
- [Qemu-devel] [PULL 00/17] QOM CPUState patch queue 2013-03-12, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 01/17] cpu: Fix qemu_get_cpu() to return NULL if CPU not found, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 03/17] cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu(), Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 10/17] target-i386: Update VMStateDescription to X86CPU, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 06/17] vmstate: Make vmstate_register() static inline, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 08/17] cpu: Register VMStateDescription through CPUState,
Andreas Färber <=
- [Qemu-devel] [PATCH 11/17] target-cris/helper.c: Update Coding Style, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 04/17] target-sh4: Introduce SuperHCPU subclasses, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 07/17] stubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 17/17] target-lm32: Update VMStateDescription to LM32CPU, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 05/17] target-sh4: Move PVR/PRR/CVR into SuperHCPUClass, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 09/17] cpu: Introduce cpu_class_set_vmsd(), Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 02/17] monitor: Use qemu_get_cpu() in monitor_set_cpu(), Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 16/17] target-arm: Override do_interrupt for ARMv7-M profile, Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 13/17] exec: Pass CPUState to cpu_reset_interrupt(), Andreas Färber, 2013/03/12
- [Qemu-devel] [PATCH 15/17] cpu: Replace do_interrupt() by CPUClass::do_interrupt method, Andreas Färber, 2013/03/12