On Thu, Jan 08, 2015 at 11:40:16AM +0530, Bharata B Rao wrote: > Support hot removal of CPU for sPAPR guests. > > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> > --- > hw/ppc/spapr.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 4347471..ec793b1 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1908,6 +1908,22 @@ static void spapr_cpu_hotplug_add(DeviceState *dev, > CPUState *cs) > drck->attach(drc, dev, fdt, offset, false); > } > > +static void spapr_cpu_release(DeviceState *dev, void *opaque) > +{ > + /* Release vCPU */
Um.. should this actually do something? > +} > + > +static void spapr_cpu_hotplug_remove(DeviceState *dev, CPUState *cs) > +{ > + PowerPCCPU *cpu = POWERPC_CPU(cs); > + int id = ppc_get_vcpu_dt_id(cpu); > + sPAPRDRConnector *drc = > + spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id); > + sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); > + > + drck->detach(drc, dev, spapr_cpu_release, NULL); > +} > + > static void spapr_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > Error **errp) > { > @@ -1948,6 +1964,21 @@ static void spapr_cpu_plug(HotplugHandler > *hotplug_dev, DeviceState *dev, > return; > } > > +static void spapr_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, > + Error **errp) > +{ > + Error *local_err = NULL; Unused variable. > + CPUState *cs = CPU(dev); > + PowerPCCPU *cpu = POWERPC_CPU(cs); > + sPAPRDRConnector *drc = > + spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, > cpu->cpu_dt_id); > + > + spapr_cpu_hotplug_remove(dev, cs); > + spapr_hotplug_req_remove_event(drc); > + error_propagate(errp, local_err); > + return; > +} > + > static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, > DeviceState *dev, Error **errp) > { > @@ -1958,6 +1989,16 @@ static void spapr_machine_device_plug(HotplugHandler > *hotplug_dev, > } > } > > +static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev, > + DeviceState *dev, Error **errp) > +{ > + if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { > + if (dev->hotplugged) { > + spapr_cpu_unplug(hotplug_dev, dev, errp); > + } > + } > +} > + > static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine, > DeviceState *dev) > { > @@ -1986,6 +2027,8 @@ static void spapr_machine_class_init(ObjectClass *oc, > void *data) > mc->get_hotplug_handler = spapr_get_hotpug_handler; > > hc->plug = spapr_machine_device_plug; > + hc->unplug = spapr_machine_device_unplug; > + > smc->dr_phb_enabled = false; > smc->dr_cpu_enabled = false; > smc->dr_lmb_enabled = false; -- 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
pgpdzCwcwgLxd.pgp
Description: PGP signature