Quoting Bharata B Rao (2015-01-08 00:10:09) > Advertise CPU DR-capability to the guest via device tree. > > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> > Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> > [spapr_drc_reset implementation] > --- > hw/ppc/spapr.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 71e7052..98a32d0 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -807,6 +807,14 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, > spapr_populate_chosen_stdout(fdt, spapr->vio_bus); > } > > + if (spapr->dr_cpu_enabled) { > + int offset = fdt_path_offset(fdt, "/cpus"); > + ret = spapr_drc_populate_dt(fdt, offset, > SPAPR_DR_CONNECTOR_TYPE_CPU); > + if (ret < 0) { > + fprintf(stderr, "Couldn't set up CPU DR device tree > properties\n"); > + } > + } > +
Doesn't hurt to add the check, but spapr_drc_populate_dt() tries to be smart enough to no-op if there's no drc's that have been created for resources of the specified type, so spapr_dr_connector_new() *should* be the only spots where it's necessary to check spapr->dr_cpu_enabled. > _FDT((fdt_pack(fdt))); > > if (fdt_totalsize(fdt) > FDT_MAX_SIZE) { > @@ -1358,6 +1366,16 @@ static SaveVMHandlers savevm_htab_handlers = { > .load_state = htab_load, > }; > > +static void spapr_drc_reset(void *opaque) > +{ > + sPAPRDRConnector *drc = opaque; > + DeviceState *d = DEVICE(drc); > + > + if (d) { > + device_reset(d); > + } > +} > + > /* pSeries LPAR / sPAPR hardware init */ > static void ppc_spapr_init(MachineState *machine) > { > @@ -1383,6 +1401,7 @@ static void ppc_spapr_init(MachineState *machine) > long load_limit, fw_size; > bool kernel_le = false; > char *filename; > + int smt = kvmppc_smt_threads(); > > msi_supported = true; > > @@ -1526,6 +1545,15 @@ static void ppc_spapr_init(MachineState *machine) > spapr->dr_cpu_enabled = smc->dr_cpu_enabled; > spapr->dr_lmb_enabled = smc->dr_lmb_enabled; > > + if (spapr->dr_cpu_enabled) { > + for (i = 0; i < max_cpus/smp_threads; i++) { > + sPAPRDRConnector *drc = > + spapr_dr_connector_new(OBJECT(machine), > + SPAPR_DR_CONNECTOR_TYPE_CPU, i * smt); > + qemu_register_reset(spapr_drc_reset, drc); > + } > + > + > /* Set up PCI */ > spapr_pci_rtas_init(); > > -- > 2.1.0