mirror of https://github.com/xemu-project/xemu.git
cpu: Register VMStateDescription through CPUState
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 <quintela@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
c71c3e99b8
commit
b170fce3dd
11
exec.c
11
exec.c
|
@ -219,7 +219,7 @@ void cpu_exec_init_all(void)
|
||||||
#endif
|
#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)
|
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()
|
VMSTATE_END_OF_LIST()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
#define vmstate_cpu_common vmstate_dummy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPUState *qemu_get_cpu(int index)
|
CPUState *qemu_get_cpu(int index)
|
||||||
|
@ -266,6 +268,7 @@ CPUState *qemu_get_cpu(int index)
|
||||||
void cpu_exec_init(CPUArchState *env)
|
void cpu_exec_init(CPUArchState *env)
|
||||||
{
|
{
|
||||||
CPUState *cpu = ENV_GET_CPU(env);
|
CPUState *cpu = ENV_GET_CPU(env);
|
||||||
|
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||||
CPUArchState **penv;
|
CPUArchState **penv;
|
||||||
int cpu_index;
|
int cpu_index;
|
||||||
|
|
||||||
|
@ -290,11 +293,15 @@ void cpu_exec_init(CPUArchState *env)
|
||||||
#if defined(CONFIG_USER_ONLY)
|
#if defined(CONFIG_USER_ONLY)
|
||||||
cpu_list_unlock();
|
cpu_list_unlock();
|
||||||
#endif
|
#endif
|
||||||
#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
|
|
||||||
vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
|
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,
|
register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
|
||||||
cpu_save, cpu_load, env);
|
cpu_save, cpu_load, env);
|
||||||
|
assert(cc->vmsd == NULL);
|
||||||
#endif
|
#endif
|
||||||
|
if (cc->vmsd != NULL) {
|
||||||
|
vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TARGET_HAS_ICE)
|
#if defined(TARGET_HAS_ICE)
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct CPUState CPUState;
|
||||||
* @class_by_name: Callback to map -cpu command line model name to an
|
* @class_by_name: Callback to map -cpu command line model name to an
|
||||||
* instantiatable CPU type.
|
* instantiatable CPU type.
|
||||||
* @reset: Callback to reset the #CPUState to its initial state.
|
* @reset: Callback to reset the #CPUState to its initial state.
|
||||||
|
* @vmsd: State description for migration.
|
||||||
*
|
*
|
||||||
* Represents a CPU family or model.
|
* Represents a CPU family or model.
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +56,8 @@ typedef struct CPUClass {
|
||||||
ObjectClass *(*class_by_name)(const char *cpu_model);
|
ObjectClass *(*class_by_name)(const char *cpu_model);
|
||||||
|
|
||||||
void (*reset)(CPUState *cpu);
|
void (*reset)(CPUState *cpu);
|
||||||
|
|
||||||
|
const struct VMStateDescription *vmsd;
|
||||||
} CPUClass;
|
} CPUClass;
|
||||||
|
|
||||||
struct KVMState;
|
struct KVMState;
|
||||||
|
|
Loading…
Reference in New Issue