Patchwork [RFC,qom-cpu,v2,7/8] target-openrisc: Register VMStateDescription for OpenRISCCPU

login
register
mail settings
Submitter Andreas Färber
Date Feb. 18, 2013, 7:42 p.m.
Message ID <1361216553-4549-8-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/221531/
State New
Headers show

Comments

Andreas Färber - Feb. 18, 2013, 7:42 p.m.
Since commit e67db06e9f6d7e514ee2a9b9b769ecd42977f6fb (target-or32: Add
target stubs and QOM cpu) a VMStateDescription existed, but
CPU_SAVE_VERSION was not set, so it was never registered.

Register it through CPUState.
Use a version_id of 1 and specify minimum versions as well.

Cc: Jia Liu <proljc@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-openrisc/cpu.c     |    2 ++
 target-openrisc/cpu.h     |    6 +++++-
 target-openrisc/machine.c |   33 +++++++++++++--------------------
 3 Dateien geändert, 20 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)
Juan Quintela - Feb. 22, 2013, 1:23 p.m.
Andreas Färber <afaerber@suse.de> wrote:
> Since commit e67db06e9f6d7e514ee2a9b9b769ecd42977f6fb (target-or32: Add
> target stubs and QOM cpu) a VMStateDescription existed, but
> CPU_SAVE_VERSION was not set, so it was never registered.
>
> Register it through CPUState.
> Use a version_id of 1 and specify minimum versions as well.
>
> Cc: Jia Liu <proljc@gmail.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

As with the others, the changes are right, you can consider the code
that I put before.

Later, Juan.

Patch

diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c
index 72d5e8d..5a7b495 100644
--- a/target-openrisc/cpu.c
+++ b/target-openrisc/cpu.c
@@ -19,6 +19,7 @@ 
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "migration/vmstate.h"
 
 /* CPUClass::reset() */
 static void openrisc_cpu_reset(CPUState *s)
@@ -148,6 +149,7 @@  static void openrisc_cpu_class_init(ObjectClass *oc, void *data)
     cc->reset = openrisc_cpu_reset;
 
     cc->class_by_name = openrisc_cpu_class_by_name;
+    cc->vmsd = &vmstate_openrisc_cpu;
 }
 
 static void cpu_register(const OpenRISCCPUInfo *info)
diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
index 419f007..cb35ea3 100644
--- a/target-openrisc/cpu.h
+++ b/target-openrisc/cpu.h
@@ -357,7 +357,11 @@  int cpu_openrisc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define cpu_handle_mmu_fault cpu_openrisc_handle_mmu_fault
 #define cpu_signal_handler cpu_openrisc_signal_handler
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#define vmstate_openrisc_cpu vmstate_dummy
+#else
+extern const struct VMStateDescription vmstate_openrisc_cpu;
+
 /* hw/openrisc_pic.c */
 void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
 
diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c
index cba9811..7d335e0 100644
--- a/target-openrisc/machine.c
+++ b/target-openrisc/machine.c
@@ -20,28 +20,21 @@ 
 #include "hw/hw.h"
 #include "hw/boards.h"
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_openrisc_cpu = {
     .name = "cpu",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT32_ARRAY(gpr, CPUOpenRISCState, 32),
-        VMSTATE_UINT32(sr, CPUOpenRISCState),
-        VMSTATE_UINT32(epcr, CPUOpenRISCState),
-        VMSTATE_UINT32(eear, CPUOpenRISCState),
-        VMSTATE_UINT32(esr, CPUOpenRISCState),
-        VMSTATE_UINT32(fpcsr, CPUOpenRISCState),
-        VMSTATE_UINT32(pc, CPUOpenRISCState),
-        VMSTATE_UINT32(npc, CPUOpenRISCState),
-        VMSTATE_UINT32(ppc, CPUOpenRISCState),
+        VMSTATE_UINT32_ARRAY(env.gpr, OpenRISCCPU, 32),
+        VMSTATE_UINT32(env.sr, OpenRISCCPU),
+        VMSTATE_UINT32(env.epcr, OpenRISCCPU),
+        VMSTATE_UINT32(env.eear, OpenRISCCPU),
+        VMSTATE_UINT32(env.esr, OpenRISCCPU),
+        VMSTATE_UINT32(env.fpcsr, OpenRISCCPU),
+        VMSTATE_UINT32(env.pc, OpenRISCCPU),
+        VMSTATE_UINT32(env.npc, OpenRISCCPU),
+        VMSTATE_UINT32(env.ppc, OpenRISCCPU),
         VMSTATE_END_OF_LIST()
     }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}