qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-4.1 v2 30/36] cpu: Introduce cpu_set_cpustat


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH for-4.1 v2 30/36] cpu: Introduce cpu_set_cpustate_pointers
Date: Mon, 29 Apr 2019 15:40:05 +0100

On Thu, 28 Mar 2019 at 23:23, Richard Henderson
<address@hidden> wrote:
>
> Consolidate some boilerplate from foo_cpu_initfn.
>
> Signed-off-by: Richard Henderson <address@hidden>
> ---

> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -371,6 +371,17 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
>
>  int cpu_exec(CPUState *cpu);
>
> +/**
> + * cpu_set_cpustate_pointers(cpu)
> + * @cpu: The cpu object
> + *
> + * Set the generic pointers in CPUState into the outer object.
> + */
> +static inline void cpu_set_cpustate_pointers(ArchCPU *cpu)
> +{
> +    cpu->parent_obj.env_ptr = &cpu->env;
> +}
> +
>  /**
>   * env_archcpu(env)
>   * @env: The architecture environment
> @@ -392,5 +403,4 @@ static inline CPUState *env_cpu(CPUArchState *env)
>  {
>      return &env_archcpu(env)->parent_obj;
>  }
> -

Stray blank line deletion.

>  #endif /* CPU_ALL_H */

> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 698dd9cb82..790670ebeb 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -282,17 +282,18 @@ static void s390_cpu_initfn(Object *obj)
>  {
>      CPUState *cs = CPU(obj);
>      S390CPU *cpu = S390_CPU(obj);
> -    CPUS390XState *env = &cpu->env;
>
> -    cs->env_ptr = env;
> +    cpu_set_cpustate_pointers(cpu);
>      cs->halted = 1;
>      cs->exception_index = EXCP_HLT;
>      object_property_add(obj, "crash-information", "GuestPanicInformation",
>                          s390_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL);
>      s390_cpu_model_register_props(obj);
>  #if !defined(CONFIG_USER_ONLY)
> -    env->tod_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu);
> -    env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
> +    cpu->env.tod_timer =
> +        timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu);
> +    cpu->env.cpu_timer =
> +        timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
>      s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
>  #endif

I would have left the local variable so that we didn't
need to change these lines, but whatever.

Reviewed-by: Peter Maydell <address@hidden>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]