spapr_cpu_core: Implement DeviceClass::reset
commitd1f2b4691a268306a319ea76f67421431f529a07
authorGreg Kurz <groug@kaod.org>
Tue, 22 Oct 2019 16:38:07 +0000 (22 18:38 +0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Thu, 24 Oct 2019 02:32:33 +0000 (24 13:32 +1100)
tree03ec5acb9f590b51e05372495a184f762ceda5f0
parent90f8db52bb7ea387ff45ac12bb73935b7fc27794
spapr_cpu_core: Implement DeviceClass::reset

Since vCPUs aren't plugged into a bus, we manually register a reset
handler for each vCPU. We also call this handler at realize time
to ensure hot plugged vCPUs are reset before being exposed to the
guest. This results in vCPUs being reset twice at machine reset.
It doesn't break anything but it is slightly suboptimal and above
all confusing.

The hotplug path in device_set_realized() already knows how to reset
a hotplugged device if the device reset handler is present. Implement
one for sPAPR CPU cores that resets all vCPUs under a core.

While here rename spapr_cpu_reset() to spapr_reset_vcpu() for
consistency with spapr_realize_vcpu() and spapr_unrealize_vcpu().

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[clg: add documentation on the reset helper usage ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191022163812.330-3-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr_cpu_core.c