From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3cou-0003hz-Jd for qemu-devel@nongnu.org; Sun, 28 Jul 2013 22:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3con-0005pS-WE for qemu-devel@nongnu.org; Sun, 28 Jul 2013 22:04:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:46326 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3con-0005p4-ND for qemu-devel@nongnu.org; Sun, 28 Jul 2013 22:04:13 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 29 Jul 2013 04:03:58 +0200 Message-Id: <1375063438-3149-3-git-send-email-afaerber@suse.de> In-Reply-To: <1375063438-3149-1-git-send-email-afaerber@suse.de> References: <1375063438-3149-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC for-next 2/2] cpu: Move VMSTATE_CPU() into TYPE_CPU VMStateDescription List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jia Liu , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Assign DeviceClass::vmsd for common CPUState and drop VMSTATE_CPU() from AlphaCPU and OpenRISCCPU. Since we have two types of CPUs, those that register their state through CPUClass::vmsd or CPU_SAVE_VERSION and those that register it through DeviceClass::vmsd, we must keep device code from registering VMState when only the base CPU class has DeviceClass::vmsd set. Signed-off-by: Andreas F=C3=A4rber --- hw/core/qdev.c | 5 +++++ include/qom/cpu.h | 4 ---- qom/cpu.c | 10 ++++++++++ stubs/vmstate.c | 1 + target-alpha/machine.c | 1 - target-openrisc/machine.c | 1 - 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0430fba..6035f64 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -685,6 +685,11 @@ static void device_register_vmstate(DeviceState *dev= , Error **errp) oc =3D object_get_class(OBJECT(dev)); do { dc =3D DEVICE_CLASS(oc); + if (oc =3D=3D object_class_by_name("cpu") && + fields =3D=3D 0 && subsections =3D=3D 0) { + /* Old-style CPU with common state as separate VMSD */ + break; + } if (dc->vmsd !=3D NULL) { if (vmsd =3D=3D NULL) { vmsd =3D dc->vmsd; diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 0d6e95c..e0ad8b6 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -507,11 +507,7 @@ void qemu_init_vcpu(CPUState *cpu); */ void cpu_single_step(CPUState *cpu, int enabled); =20 -#ifdef CONFIG_SOFTMMU extern const struct VMStateDescription vmstate_cpu_common; -#else -#define vmstate_cpu_common vmstate_dummy -#endif =20 #define VMSTATE_CPU() { = \ .name =3D "parent_obj", = \ diff --git a/qom/cpu.c b/qom/cpu.c index dbc9fb6..a3e47cb 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -24,6 +24,7 @@ #include "qemu/notify.h" #include "qemu/log.h" #include "sysemu/sysemu.h" +#include "migration/vmstate.h" =20 typedef struct CPUExistsArgs { int64_t id; @@ -250,6 +251,14 @@ static int64_t cpu_common_get_arch_id(CPUState *cpu) return cpu->cpu_index; } =20 +static const VMStateDescription vmstate_cpu_device =3D { + .name =3D "CPU", + .fields =3D (VMStateField[]) { + VMSTATE_CPU(), + VMSTATE_END_OF_LIST() + }, +}; + static void cpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -268,6 +277,7 @@ static void cpu_class_init(ObjectClass *klass, void *= data) k->gdb_write_register =3D cpu_common_gdb_write_register; dc->realize =3D cpu_common_realizefn; dc->no_user =3D 1; + dc->vmsd =3D &vmstate_cpu_device; } =20 static const TypeInfo cpu_type_info =3D { diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 778bc3f..22e2bd4 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -2,6 +2,7 @@ #include "migration/vmstate.h" =20 const VMStateDescription vmstate_dummy =3D {}; +const VMStateDescription vmstate_cpu_common =3D {}; =20 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, diff --git a/target-alpha/machine.c b/target-alpha/machine.c index 889f2fc..e3e75fb 100644 --- a/target-alpha/machine.c +++ b/target-alpha/machine.c @@ -77,7 +77,6 @@ static const VMStateDescription vmstate_env =3D { }; =20 static VMStateField vmstate_cpu_fields[] =3D { - VMSTATE_CPU(), VMSTATE_STRUCT(env, AlphaCPU, 1, vmstate_env, CPUAlphaState), VMSTATE_END_OF_LIST() }; diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c index 6f864fe..372b261 100644 --- a/target-openrisc/machine.c +++ b/target-openrisc/machine.c @@ -45,7 +45,6 @@ const VMStateDescription vmstate_openrisc_cpu =3D { .minimum_version_id =3D 1, .minimum_version_id_old =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_CPU(), VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCStat= e), VMSTATE_END_OF_LIST() } --=20 1.8.1.4