From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFXxX-0007NG-3H for qemu-devel@nongnu.org; Tue, 21 Jun 2016 22:32:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFXxN-0008Pm-MR for qemu-devel@nongnu.org; Tue, 21 Jun 2016 22:32:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFXxN-0008PM-Cq for qemu-devel@nongnu.org; Tue, 21 Jun 2016 22:31:57 -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 u5M2TNv6143186 for ; Tue, 21 Jun 2016 22:31:56 -0400 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0a-001b2d01.pphosted.com with ESMTP id 23q6ykcxmb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Jun 2016 22:31:55 -0400 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Jun 2016 12:31:53 +1000 Date: Wed, 22 Jun 2016 08:01:44 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <1466238846-21365-1-git-send-email-bharata@linux.vnet.ibm.com> <5768D8DC.4060304@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5768D8DC.4060304@redhat.com> Message-Id: <20160622023144.GC5613@in.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0 1/1] spapr: Support setting of compat CPU type for CPU cores List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, imammedo@redhat.com On Tue, Jun 21, 2016 at 08:04:12AM +0200, Thomas Huth wrote: > On 18.06.2016 10:34, Bharata B Rao wrote: > > Compat CPU type is typically specified on -cpu cmdline option like: > > -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. > > With the introduction of sPAPR CPU core devices, we need to support > > the same for core devices too. > > > > Support the specification of CPU compat type on device_add command for > > sPAPRCPUCore devices like: > > (qemu) device_add POWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24 > > > > Signed-off-by: Bharata B Rao > > --- > > Applies on ppc-for-2.7 branch of David Gibson's tree. > > > > hw/ppc/spapr.c | 8 +++++ > > hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ > > include/hw/ppc/spapr_cpu_core.h | 2 ++ > > 3 files changed, 83 insertions(+) > [...] > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > > index 3a5da09..9eb63cc 100644 > > --- a/hw/ppc/spapr_cpu_core.c > > +++ b/hw/ppc/spapr_cpu_core.c > > @@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) > > return core_type; > > } > > > > +/* > > + * Returns the CPU compat type specified in -cpu @model. > > + */ > > +char *spapr_get_cpu_compat_type(const char *model) > > +{ > > + char *compat_type = NULL; > > + gchar **model_pieces = g_strsplit(model, ",", 2); > > + > > + if (model_pieces[1]) { > > + gchar **compat_pieces = g_strsplit(model_pieces[1], "=", 2); > > + > > + compat_type = g_strdup_printf("%s", compat_pieces[1]); > > + } > > + > > + g_strfreev(model_pieces); > > + return compat_type; > > +} > > Shouldn't you check for "compat=" somewhere in this function (and > properly iterate over all parts of the comma separated string)? In case > we support more properties than "compat=" some day, this will go wrong > otherwise... Currently since it is only "compat=", anything else would fail gracefully when the property gets set. But obviously that is not future-safe as you note. Let me rework on this. Regards, Bharata