qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 7/7] i386/cpu: add instance finalize callback


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH v3 7/7] i386/cpu: add instance finalize callback
Date: Thu, 29 Jan 2015 16:25:44 +0100

On Wed, 14 Jan 2015 15:27:30 +0800
Zhu Guihua <address@hidden> wrote:

> From: Gu Zheng <address@hidden>
> 
> Add a func to finalize a cpu's instance. When cpu's device_add failed,
> and cpu's device_del executed, this func would be invoked.
> 
> Signed-off-by: Gu Zheng <address@hidden>
> Signed-off-by: Zhu Guihua <address@hidden>
> ---
>  include/qom/cpu.h | 1 +
>  target-i386/cpu.c | 8 ++++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 936afcd..f663199 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -305,6 +305,7 @@ struct CPUState {
>  QTAILQ_HEAD(CPUTailQ, CPUState);
>  extern struct CPUTailQ cpus;
>  #define CPU_NEXT(cpu) QTAILQ_NEXT(cpu, node)
> +#define CPU_REMOVE(cpu) QTAILQ_REMOVE(&cpus, cpu, node)
>  #define CPU_FOREACH(cpu) QTAILQ_FOREACH(cpu, &cpus, node)
>  #define CPU_FOREACH_SAFE(cpu, next_cpu) \
>      QTAILQ_FOREACH_SAFE(cpu, &cpus, node, next_cpu)
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 4347948..4746814 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -2983,6 +2983,13 @@ static void x86_cpu_initfn(Object *obj)
>      }
>  }
>  
> +static void x86_cpu_finalizefn(Object *obj)
> +{
> +    CPUState *cs = CPU(obj);
> +
> +    CPU_REMOVE(cs);
> +}


issue with reliance on cpu_index is not solved completely,
There is still a lot of places that use cpu_index and when
we start ignore it in x86 CPU, the rest of the places probably
would have a broken logic. Please look at that call sites,
and if they are fine with it, especially common files shared
with other targets.

> +
>  static int64_t x86_cpu_get_arch_id(CPUState *cs)
>  {
>      X86CPU *cpu = X86_CPU(cs);
> @@ -3095,6 +3102,7 @@ static const TypeInfo x86_cpu_type_info = {
>      .parent = TYPE_CPU,
>      .instance_size = sizeof(X86CPU),
>      .instance_init = x86_cpu_initfn,
> +    .instance_finalize = x86_cpu_finalizefn,
>      .abstract = true,
>      .class_size = sizeof(X86CPUClass),
>      .class_init = x86_cpu_common_class_init,




reply via email to

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