cpu: Introduce cpu_class_set_vmsd()
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Am 26.02.2013 20:32, schrieb Eduardo Habkost:
Quoted 37 lines · Andreas Färber
Quoted 21 lines
This setter avoids redefining each VMStateDescription value to
vmstate_dummyby not referencing the value forCONFIG_USER_ONLY.Suggested-by Juan Quintela <[email protected]>Signed-off-by Andreas Färber <[email protected]>--- include/qom/cpu.h | 17 +++++++++++++++++1 Datei geändert, 17 Zeilen hinzugefügt(+)
include/qom/cpu.h +4
-0@@ -135,6 +135,23 @@ void cpu_reset(CPUState *cpu);ObjectClass *cpu_class_by_name (const char *typename,const char *cpu_model);/** +* cpu_class_set_vmsd: +* @cc: CPU class +* @value: Value to set. +* include/qom/cpu.h void cpu_reset(CPUState *cpu); · line 151
Quoted 10 lines
include/qom/cpu.h +10
-0+* Sets #VMStateDescription for @cc. +*/ +#ifndef CONFIG_USER_ONLY +static inline void cpu_class_set_vmsd (CPUClass *cc, +const struct VMStateDescription *value) +{ + cc->vmsd = value; +} +#else +#define cpu_class_set_vmsd (cpu, val) ((cpu)->vmsd = NULL)Even after reading the description above, I was going to ask you why this was not an inline function as well. But then I read patch 5/6 and understood why. :-)
Quoted 2 lines
I would add a coment here noting that "val" is actually expected to be never evaluated when
CONFIG_USER_ONLYis defined.
Done. I also renamed the arguments to match those of the function.
Quoted 2 lines
Reviewed-by Eduardo Habkost <[email protected]>
Thanks,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH qom-cpu v3 0/6] QOM CPUState VMStateDescriptions
In reply to a message not in the archiveAm 25.02.2013 19:22, schrieb Andreas Färber:
Quoted 6 lines
Andreas Färber (6):
vmstate: Makevmstate_register()static inline
stubs: Add avmstate_dummystruct forCONFIG_USER_ONLY
cpu: Register VMStateDescription through CPUState
cpu: Introducecpu_class_set_vmsd()
target-i386: Update VMStateDescription to X86CPU
Applied these to qom-cpu (with change suggested by Eduardo):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Quoted 1 line
target-lm32: Update VMStateDescription to LM32CPU
Juan/Michael, could you take a look at this one?
Thanks,
Andreas
Quoted 15 lines
exec.c | 11 ++- include/migration/vmstate.h | 16 +++- include/qom/cpu.h | 20 ++++ savevm.c | 7 -- stubs/vmstate.c | 2 + target-i386/cpu-qom.h | 4 + target-i386/cpu.c | 2 + target-i386/cpu.h | 2 - target-i386/machine.c | 215 +++++++++++++++++++++---------------------- target-lm32/cpu-qom.h | 4 + target-lm32/cpu.c | 2 + target-lm32/cpu.h | 2 - target-lm32/machine.c | 25 ++---13 Dateien geändert, 177 Zeilen hinzugefügt(+), 135 Zeilen entfernt(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
A message that is not in the archive (sent off-list or not yet received): [email protected]
Michael Walle
Acked-byRe: [Qemu-devel] [PATCH qom-cpu v3 6/6] target-lm32: Update VMStateDescription to LM32CPU
Am Montag 25 Februar 2013, 19:22:50 schrieb Andreas Färber:
Quoted 4 lines
Add a
vmstate_lm32_cpureferencing the previous VMStateDescription as a sub-struct and hook it up toCPUClass::vmsd. Drop cpu_{save,load}().Signed-off-by Andreas Färber <[email protected]>
Quoted 88 lines
--- target-lm32/cpu-qom.h | 4 ++++ target-lm32/cpu.c | 2 ++ target-lm32/cpu.h | 2 -- target-lm32/machine.c | 25 +++++++++++++------------4 Dateien geändert, 19 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)
target-lm32/cpu-qom.h +4
-0@@ -71,4 +71,8 @@ static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env)#define ENV_OFFSET offsetof(LM32CPU, env) +#ifndef CONFIG_USER_ONLY +extern const struct VMStateDescription vmstate_lm32_cpu; +#endif +#endif
target-lm32/cpu.c +2
-0@@ -83,6 +83,8 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) lcc->parent_reset = cc->reset; cc->reset = lm32_cpu_reset; + +cpu_class_set_vmsd (cc, &vmstate_lm32_cpu); }static const TypeInfo
lm32_cpu_type_info= {target-lm32/cpu.h +0
-2@@ -212,8 +212,6 @@ static inline CPULM32State *cpu_init(const char *cpu_model) #define cpu_gen_code cpu_lm32_gen_code#define cpu_signal_handler cpu_lm32_signal_handler -#define CPU_SAVE_VERSION 1 -int cpu_lm32_handle_mmu_fault (CPULM32State *env,target_ulong address,int rw,int mmu_idx);#define cpu_handle_mmu_fault cpu_lm32_handle_mmu_faulttarget-lm32/machine.c +13
-12@@ -1,9 +1,9 @@#include "hw/hw.h" #include "hw/boards.h" -static const VMStateDescription vmstate_cpu = { - .name ="cpu" , - .version_id =CPU_SAVE_VERSION , +static const VMStateDescription vmstate_env = { + .name ="env" , + .version_id =1 , .minimum_version_id =1 , .minimum_version_id_old =1 , .fields = (VMStateField []) {@@ -22,12 +22,13 @@ static const VMStateDescription vmstate_cpu = { } }; -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); -} +const VMStateDescription vmstate_lm32_cpu = { + .name ="cpu" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (env,LM32CPU ,1 , vmstate_env, CPULM32State), +VMSTATE_END_OF_LIST () + } +};