qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 3/3] exec: call cpu_exec_exit() from a CPU un


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH v3 3/3] exec: call cpu_exec_exit() from a CPU unrealize common function
Date: Mon, 17 Oct 2016 14:43:32 +1100
User-agent: Mutt/1.7.0 (2016-08-17)

On Sat, Oct 15, 2016 at 12:52:49AM +0200, Laurent Vivier wrote:
> As cpu_exec_exit() mirrors the cpu_exec_realizefn(),
> rename it as cpu_exec_unrealizefn().
> 
> Create and register a cpu_common_unrealizefn() function for
> the CPU device class and call cpu_exec_unrealizefn() from
> this function.
> 
> Remove cpu_exec_exit() from cpu_common_finalize()
> (which mirrors init, not realize), and as x86_cpu_unrealizefn()
> overwrites the device class unrealize function, add a call to
> cpu_exec_unrealizefn() (as in ppc_cpu_unrealizefn()).
> 
> Signed-off-by: Laurent Vivier <address@hidden>

Reviewed-by: David Gibson <address@hidden>

> ---
>  exec.c                      | 2 +-
>  include/qom/cpu.h           | 2 +-
>  qom/cpu.c                   | 8 +++++++-
>  target-i386/cpu.c           | 2 ++
>  target-ppc/translate_init.c | 2 +-
>  5 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index 203eb52..3cd25db 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -596,7 +596,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int 
> asidx)
>  }
>  #endif
>  
> -void cpu_exec_exit(CPUState *cpu)
> +void cpu_exec_unrealizefn(CPUState *cpu)
>  {
>      CPUClass *cc = CPU_GET_CLASS(cpu);
>  
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 5520c6c..633c3fc 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -948,7 +948,7 @@ void QEMU_NORETURN cpu_abort(CPUState *cpu, const char 
> *fmt, ...)
>      GCC_FMT_ATTR(2, 3);
>  void cpu_exec_initfn(CPUState *cpu);
>  void cpu_exec_realizefn(CPUState *cpu, Error **errp);
> -void cpu_exec_exit(CPUState *cpu);
> +void cpu_exec_unrealizefn(CPUState *cpu);
>  
>  #ifdef CONFIG_SOFTMMU
>  extern const struct VMStateDescription vmstate_cpu_common;
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 85f1132..03d9190 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -345,6 +345,12 @@ static void cpu_common_realizefn(DeviceState *dev, Error 
> **errp)
>      trace_init_vcpu(cpu);
>  }
>  
> +static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
> +{
> +    CPUState *cpu = CPU(dev);
> +    cpu_exec_unrealizefn(cpu);
> +}
> +
>  static void cpu_common_initfn(Object *obj)
>  {
>      CPUState *cpu = CPU(obj);
> @@ -369,7 +375,6 @@ static void cpu_common_initfn(Object *obj)
>  static void cpu_common_finalize(Object *obj)
>  {
>      CPUState *cpu = CPU(obj);
> -    cpu_exec_exit(cpu);
>      g_free(cpu->trace_dstate);
>  }
>  
> @@ -403,6 +408,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
>      k->cpu_exec_exit = cpu_common_noop;
>      k->cpu_exec_interrupt = cpu_common_exec_interrupt;
>      dc->realize = cpu_common_realizefn;
> +    dc->unrealize = cpu_common_unrealizefn;
>      /*
>       * Reason: CPUs still need special care by board code: wiring up
>       * IRQs, adding reset handlers, halting non-first CPUs, ...
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 3476d46..399a3e4 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -3253,6 +3253,8 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Error 
> **errp)
>          object_unparent(OBJECT(cpu->apic_state));
>          cpu->apic_state = NULL;
>      }
> +
> +    cpu_exec_unrealizefn(CPU(dev));
>  }
>  
>  typedef struct BitProperty {
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 40dae70..2de6a06 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -9910,7 +9910,7 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error 
> **errp)
>      opc_handler_t **table, **table_2;
>      int i, j, k;
>  
> -    cpu_exec_exit(CPU(dev));
> +    cpu_exec_unrealizefn(CPU(dev));
>  
>      for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
>          if (env->opcodes[i] == &invalid_handler) {

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

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