From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOqRN-0007a3-LG for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:28:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOqRI-0006hS-Mf for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:28:33 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41813 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOqRI-0006hC-G2 for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:28:28 -0500 Message-ID: <54E7609E.6020302@suse.de> Date: Fri, 20 Feb 2015 17:28:14 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1424183053-4310-1-git-send-email-mimu@linux.vnet.ibm.com> <1424183053-4310-14-git-send-email-mimu@linux.vnet.ibm.com> <54E73EB2.6050700@suse.de> <20150220163209.4e082e0b@bee> <54E755BD.5000705@suse.de> <20150220170408.49db6da5@bee> In-Reply-To: <20150220170408.49db6da5@bee> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH v2 13/15] cpu-model/s390: Add processor property routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Mueller Cc: linux-s390@vger.kernel.org, qemu-devel@nongnu.org, kvm@vger.kernel.org, Gleb Natapov , linux-kernel@vger.kernel.org, Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Richard Henderson Am 20.02.2015 um 17:04 schrieb Michael Mueller: > On Fri, 20 Feb 2015 16:41:49 +0100 > Andreas F=C3=A4rber wrote: >=20 >> Can't you just implement the class-level name-to-ObjectClass callback >> that other CPUs have grown for the above use case? >=20 > If it fulfills the requirements sure. Please point me to an example, Take a look at include/qom/cpu.h CPUClass::class_by_name and git-grep the existing targets - most implement it already. It's a generic hook to be used from everywhere rather than a local function specific to the legacy init function. Apart from the error handling it should be straight-forward. > sounds that > s390_select_cpu_model() is doing something similar to that, just that i= t hooks in > the s390_set_processor_props() call. >=20 > const char *s390_select_cpu_model(const char *model) > { > S390ProcessorProps proc; > const char *typename; > S390CPUClass *cc; >=20 > /* return already selected cpu typename */ > typename =3D s390_cpu_typename(); > if (typename) { > goto out; > } >=20 > /* return standard cpu typename when cpu models are unavailable */ > typename =3D TYPE_S390_CPU; > if (!s390_cpu_classes_initialized() || !model) { > goto out; > } > cc =3D S390_CPU_CLASS(s390_cpu_class_by_name(model)); > if (!cc) { > goto out; > } > proc.cpuid =3D cpuid(cc->proc); > proc.ibc =3D cc->proc->ibc; > memcpy(proc.fac_list, cc->fac_list, S390_ARCH_FAC_LIST_SIZE_BYTE); > if (s390_set_processor_props(&proc)) { > goto out; > } Sorry for my ignorance, but what is proc actually needed for? For initializing the class, there's .class_init (and cc->fac_list apparently is initialized here). If you need to pass info to KVM, you can do so in DeviceClass::realize when the vCPU actually goes "live". A string-to-string (or string-to-ObjectClass) translation function seems like a weird point in time to take action with global effect. Anyway, please implement the generic callback, then you can still call it from your own helper functions if needed. Regards, Andreas >=20 > /* return requested cpu typename in success case */ > typename =3D object_class_get_name((ObjectClass *) cc); > out: > selected_cpu_typename =3D typename; > trace_select_cpu_model(model, typename); > return typename; > } --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG N=C3=BCrnberg)