Bharata B Rao <bhar...@linux.vnet.ibm.com> writes:

> xics maintains an array of ICPState structures which is indexed
> by cpu_index. Change this to index the ICPState array by migration_id
> for pseries-2.7 onwards. This allows migration of guest to suceed
> when there are holes in cpu_index range due to CPU hot removal.
>
> NOTE: In rtas_set_xive() and h_ipi(), cpu_dt_id is implicitly
> assume to be equivalent to migration_id.
>
> Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com>
> ---
>  hw/intc/xics.c       | 12 ++++++++----
>  hw/intc/xics_kvm.c   | 11 +++++------
>  hw/intc/xics_spapr.c | 28 +++++++++++++++++++++-------
>  3 files changed, 34 insertions(+), 17 deletions(-)
>
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index cd48f42..ce7571e 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -50,9 +50,11 @@ int xics_get_cpu_index_by_dt_id(int cpu_dt_id)
>  void xics_cpu_destroy(XICSState *xics, PowerPCCPU *cpu)
>  {
>      CPUState *cs = CPU(cpu);
> -    ICPState *ss = &xics->ss[cs->cpu_index];
> +    CPUClass *cc = CPU_GET_CLASS(cs);
> +    int server = cc->get_migration_id(cs);
> +    ICPState *ss = &xics->ss[server];

A helper like this will make code much more compact at other places:

static inline int xics_get_server(PowerPCCPU cpu)
{
    CPUState *cs = CPU(cpu);
    CPUClass *cc = CPU_GET_CLASS(cs);

    return cc->get_migration_id(cs);
}


void xics_cpu_destroy(XICSState *xics, PowerPCCPU *cpu)
{
    int server = xics_get_server(cpu);
    ICPState *ss = &xics->ss[server];
....

}

Regards
Nikunj


Reply via email to