Re: [Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU

2012-01-30 Thread Andreas Färber
Am 30.01.2012 03:22, schrieb Anthony Liguori: > On 01/29/2012 07:25 AM, Andreas Färber wrote: >> +static void arm_cpu_realize(Object *obj) >> +{ >> +ARMCPU *cpu = ARM_CPU(obj); >> +ARMCPUClass *cpu_class = ARM_CPU_GET_CLASS(obj); >> + >> +memset(&cpu->env, 0, sizeof(CPUARMState)); >> +

Re: [Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU

2012-01-30 Thread Andreas Färber
Am 30.01.2012 03:22, schrieb Anthony Liguori: > On 01/29/2012 07:25 AM, Andreas Färber wrote: >> +#define ENV_GET_OBJECT(e) \ >> +(Object *)((void *)(e) - offsetof(ARMCPU, env)) > > sizeof(CPU) should be sizeof(void *). Not following... CPU is a struct, so: sizeof(ARMCPU) > sizeof(CPU) >= siz

Re: [Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU

2012-01-29 Thread Anthony Liguori
On 01/29/2012 07:25 AM, Andreas Färber wrote: We g_malloc0()'ed CPUARMState ourself, and exec.c's cpu_copy() runs through cpu_init() as well, so we are at liberty to supply the CPUState any way we see fit. Having CPUARMState as field in the QOM CPU allows both to access env from an ARMCPU object

[Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU

2012-01-29 Thread Andreas Färber
We g_malloc0()'ed CPUARMState ourself, and exec.c's cpu_copy() runs through cpu_init() as well, so we are at liberty to supply the CPUState any way we see fit. Having CPUARMState as field in the QOM CPU allows both to access env from an ARMCPU object and to access the QOM Object and its ObjectClass