From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVG9K-000554-QH for qemu-devel@nongnu.org; Thu, 04 Aug 2016 06:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVG9C-0002Vq-1B for qemu-devel@nongnu.org; Thu, 04 Aug 2016 06:45:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57201 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVG9B-0002VU-RC for qemu-devel@nongnu.org; Thu, 04 Aug 2016 06:45:05 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u74Aisvm141320 for ; Thu, 4 Aug 2016 06:45:04 -0400 Received: from e28smtp09.in.ibm.com (e28smtp09.in.ibm.com [125.16.236.9]) by mx0b-001b2d01.pphosted.com with ESMTP id 24kkan4u87-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 04 Aug 2016 06:45:04 -0400 Received: from localhost by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Aug 2016 16:15:00 +0530 Date: Thu, 4 Aug 2016 16:14:53 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <1470201951-19288-1-git-send-email-david@gibson.dropbear.id.au> <1470201951-19288-2-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1470201951-19288-2-git-send-email-david@gibson.dropbear.id.au> Message-Id: <20160804104453.GB13652@in.ibm.com> Subject: Re: [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: peter.maydell@linaro.org, agraf@suse.de, pbonzini@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org On Wed, Aug 03, 2016 at 03:25:50PM +1000, David Gibson wrote: > From: Bharata B Rao > > CPU hotplug and coldplug aren't supported prior to pseries-2.7. Further, > earlier machine types don't use CPU core objects at all. These mean that > query-hotpluggable-cpus and coldplug on older pseries machines will crash > QEMU. It also means that hotpluggable_cpus flag in query-machines will > be incorrectly set to true for pseries < 2.7, since it is based on the > presence of the query_hotpluggable_cpus hook. > > - Don't assign the query_hotpluggable_cpus hook for pseries < 2.7 > - query_hotpluggable_cpus should therefore never be called on pseries < > 2.7, so add an assert > - spapr_core_pre_plug() should fail hot/cold plug attempts for pseries < > 2.7, since core objects are never used there > - spapr_core_plug() should therefore never be called for pseries < 2.7, so > add an assert. > > Signed-off-by: Bharata B Rao > [dwg: Change from query_hotpluggable_cpus returning NULL for pseries < 2.7 > to not being called at all, reword commit message for accuracy] > Signed-off-by: David Gibson > --- > hw/ppc/spapr.c | 7 ++++++- > hw/ppc/spapr_cpu_core.c | 19 ++++++------------- > 2 files changed, 12 insertions(+), 14 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index fbbd051..bce2371 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2376,8 +2376,11 @@ static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine) > int i; > HotpluggableCPUList *head = NULL; > sPAPRMachineState *spapr = SPAPR_MACHINE(machine); > + sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine); > int spapr_max_cores = max_cpus / smp_threads; > > + g_assert(smc->dr_cpu_enabled); > + > for (i = 0; i < spapr_max_cores; i++) { > HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1); > HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1); > @@ -2432,7 +2435,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > hc->plug = spapr_machine_device_plug; > hc->unplug = spapr_machine_device_unplug; > mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id; > - mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus; > + if (smc->dr_cpu_enabled) { > + mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus; > + } > > smc->dr_lmb_enabled = true; > smc->dr_cpu_enabled = true; Unfortunately smc->dr_cpu_enabled is always false when you set mc->query_hotpluggable_cpus and will be set to true immediately afterwards as seen in above hunk. This leads to query-hotpluggable-cpus being unavailable for all machine type versions. Your first version of setting mc->query_hotpluggable_cpus to NULL explicitly for 2.6 and downwards was correct. Regards, Bharata.