Skip to content

Commit

Permalink
cpu: Register VMStateDescription through CPUState
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
afaerber committed Feb 2, 2013
1 parent 62668f6 commit cfb9d11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions exec.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -266,6 +266,9 @@ CPUState *qemu_get_cpu(int index)
void cpu_exec_init(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
#if !defined(CONFIG_USER_ONLY) && !defined(CPU_SAVE_VERSION)
CPUClass *cc = CPU_GET_CLASS(cpu);
#endif
CPUArchState **penv;
int cpu_index;

Expand All @@ -290,10 +293,16 @@ void cpu_exec_init(CPUArchState *env)
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif
#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
#if !defined(CONFIG_USER_ONLY)
vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
#if defined(CPU_SAVE_VERSION)
register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
cpu_save, cpu_load, env);
#else
if (cc->vmsd != NULL) {
vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
}
#endif
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions include/qom/cpu.h
Expand Up @@ -43,6 +43,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.
*/
Expand All @@ -54,6 +55,8 @@ typedef struct CPUClass {
ObjectClass *(*class_by_name)(const char *cpu_model);

void (*reset)(CPUState *cpu);

const struct VMStateDescription *vmsd;
} CPUClass;

struct KVMState;
Expand Down

0 comments on commit cfb9d11

Please sign in to comment.