qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>, quintela@redhat.com
Subject: [Qemu-devel] [PATCH RFC qom-cpu-next 1/6] cpu: Register VMStateDescription through CPUState
Date: Sat,  2 Feb 2013 16:04:11 +0100	[thread overview]
Message-ID: <1359817456-25561-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1359817456-25561-1-git-send-email-afaerber@suse.de>

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>
---
 exec.c            |   13 +++++++++++--
 include/qom/cpu.h |    3 +++
 2 Dateien geändert, 14 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/exec.c b/exec.c
index b85508b..5eee174 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)
 {
@@ -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;
 
@@ -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
 }
 
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 46f2247..b870752 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -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.
  */
@@ -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;
-- 
1.7.10.4

  reply	other threads:[~2013-02-02 15:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-02 15:04 [Qemu-devel] [PATCH RFC qom-cpu-next 0/6] QOM CPUState VMStateDescriptions Andreas Färber
2013-02-02 15:04 ` Andreas Färber [this message]
2013-02-02 15:04 ` [Qemu-devel] [PATCH RFC qom-cpu-next 2/6] target-i386: Update VMStateDescription to X86CPU Andreas Färber
2013-02-02 15:04 ` [Qemu-devel] [PATCH RFC qom-cpu-next 3/6] target-lm32: Update VMStateDescription to LM32CPU Andreas Färber
2013-02-02 15:04 ` [Qemu-devel] [RFC qom-cpu-next 4/6] target-alpha: Register VMStateDescription for AlphaCPU Andreas Färber
2013-02-02 15:04 ` [Qemu-devel] [RFC qom-cpu-next 5/6] target-openrisc: Register VMStateDescription for OpenRISCCPU Andreas Färber
2013-02-02 15:04 ` [Qemu-devel] [RFC qom-cpu-next 6/6] cpu: Guard cpu_{save, load}() definitions Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359817456-25561-2-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).