Excerpts from Fabiano Rosas's message of February 25, 2022 4:58 am: > This adds migration support for TCG pseries machines running a KVM-HV > guest. > > The state that needs to be migrated is: > > - the nested PTCR value; > - the in_nested flag; > - the nested_tb_offset. > - the saved host CPUPPCState structure; > > Signed-off-by: Fabiano Rosas <faro...@linux.ibm.com>
The series generally looks good to me, I guess patches 1 and 2 are fixes that could go ahead. Main thing about this is I was thinking of cutting down the CPUPPCState structure for saving the host state when in the L2, and making a specific structure for that that only contains what is required. This patch could easily switch to that so it's no big deal AFAIKS. > diff --git a/target/ppc/machine.c b/target/ppc/machine.c > index 7ee1984500..ae09b1bcfe 100644 > --- a/target/ppc/machine.c > +++ b/target/ppc/machine.c > @@ -10,6 +10,7 @@ > #include "kvm_ppc.h" > #include "power8-pmu.h" > #include "hw/ppc/ppc.h" > +#include "hw/ppc/spapr_cpu_core.h" > > static void post_load_update_msr(CPUPPCState *env) > { > @@ -679,6 +680,48 @@ static const VMStateDescription vmstate_tb_env = { > } > }; > > +static const VMStateDescription vmstate_hdecr = { > + .name = "cpu/hdecr", > + .version_id = 1, > + .minimum_version_id = 1, > + .fields = (VMStateField[]) { > + VMSTATE_UINT64(hdecr_next, ppc_tb_t), > + VMSTATE_TIMER_PTR(hdecr_timer, ppc_tb_t), > + VMSTATE_END_OF_LIST() > + } > +}; > + > +static bool nested_needed(void *opaque) > +{ > + PowerPCCPU *cpu = opaque; > + SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu); > + > + return spapr_cpu->in_nested; > +} I don't know the migration code -- are you assured of having a spapr CPU here? Maybe this could call a helper function located near the spapr/nested code like 'return ppc_cpu_need_hdec_migrate(cpu)' ? Thanks, Nick