From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJFwo-0007ia-9e for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJFwj-0000RO-W5 for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:06:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJFwj-0000RF-O7 for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:06:37 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u62846Rh094008 for ; Sat, 2 Jul 2016 04:06:34 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 23x8wt91s2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 02 Jul 2016 04:06:34 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 2 Jul 2016 18:06:31 +1000 Date: Sat, 2 Jul 2016 13:36:22 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <146741287399.948.15988269239450224065.stgit@bahia.lan> <146741290890.948.9125710372347515263.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <146741290890.948.9125710372347515263.stgit@bahia.lan> Message-Id: <20160702080622.GH21596@in.ibm.com> Subject: Re: [Qemu-devel] [PATCH v2 4/7] ppc: open code cpu creation for machine types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: David Gibson , Benjamin Herrenschmidt , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , Scott Wood , Igor Mammedov On Sat, Jul 02, 2016 at 12:41:48AM +0200, Greg Kurz wrote: > If we want to generate cpu_dt_id in the machine code, this must occur > before the cpu gets realized. We must open code the cpu creation to be > able to do this. > > This patch just does that. It borrows some lines from previous work > from Bharata to handle the feature parsing. > > Signed-off-by: Greg Kurz > --- > hw/ppc/ppc.c | 39 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c > index dc3d214009c5..57f4ddd073d0 100644 > --- a/hw/ppc/ppc.c > +++ b/hw/ppc/ppc.c > @@ -32,6 +32,7 @@ > #include "sysemu/cpus.h" > #include "hw/timer/m48t59.h" > #include "qemu/log.h" > +#include "qapi/error.h" > #include "qemu/error-report.h" > #include "hw/loader.h" > #include "sysemu/kvm.h" > @@ -1353,5 +1354,41 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) > > PowerPCCPU *ppc_cpu_init(const char *cpu_model) > { > - return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); > + PowerPCCPU *cpu; > + CPUClass *cc; > + ObjectClass *oc; > + gchar **model_pieces; > + Error *err = NULL; > + > + model_pieces = g_strsplit(cpu_model, ",", 2); > + if (!model_pieces[0]) { > + error_report("Invalid/empty CPU model name"); > + return NULL; > + } > + > + oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]); > + if (oc == NULL) { > + error_report("Unable to find CPU definition: %s", model_pieces[0]); > + return NULL; > + } > + > + cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); > + > + cc = CPU_CLASS(oc); > + cc->parse_features(CPU(cpu), model_pieces[1], &err); Igor is working on a patchset to convert -cpu features into global properties. IIUC, after that patchset, it is not recommended to parse the -cpu features for every CPU but do it only once. That is what I attempted here in the context of supporting compat cpu type for pseries-2.7: https://www.mail-archive.com/qemu-devel@nongnu.org/msg381660.html Regards, Bharata.