cpu: Introduce VMSTATE_CPU() macro for CPUState
authorAndreas Färber <afaerber@suse.de>
Mon, 17 Jun 2013 02:09:11 +0000 (04:09 +0200)
committerAndreas Färber <afaerber@suse.de>
Fri, 28 Jun 2013 11:25:11 +0000 (13:25 +0200)
To be used to embed common CPU state into CPU subclasses.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
exec.c
include/qom/cpu.h

diff --git a/exec.c b/exec.c
index f99041b748e1fe4935c3fa8eb5817e7f16b8f1da..0b172b45a65563b3b7c49586b26752ab497f890a 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -330,7 +330,7 @@ static int cpu_common_post_load(void *opaque, int version_id)
     return 0;
 }
 
-static const VMStateDescription vmstate_cpu_common = {
+const VMStateDescription vmstate_cpu_common = {
     .name = "cpu_common",
     .version_id = 1,
     .minimum_version_id = 1,
@@ -342,8 +342,7 @@ static const VMStateDescription vmstate_cpu_common = {
         VMSTATE_END_OF_LIST()
     }
 };
-#else
-#define vmstate_cpu_common vmstate_dummy
+
 #endif
 
 CPUState *qemu_get_cpu(int index)
index 397219b560eff1dd6788e807d9a68d888dfdee2c..3e8cc479bd43d48de303fe5d1d46737e05eb34d4 100644 (file)
@@ -378,4 +378,18 @@ void cpu_reset_interrupt(CPUState *cpu, int mask);
  */
 void cpu_resume(CPUState *cpu);
 
+#ifdef CONFIG_SOFTMMU
+extern const struct VMStateDescription vmstate_cpu_common;
+#else
+#define vmstate_cpu_common vmstate_dummy
+#endif
+
+#define VMSTATE_CPU() {                                                     \
+    .name = "parent_obj",                                                   \
+    .size = sizeof(CPUState),                                               \
+    .vmsd = &vmstate_cpu_common,                                            \
+    .flags = VMS_STRUCT,                                                    \
+    .offset = 0,                                                            \
+}
+
 #endif