Received: from eggs.gnu.org ([208.118.235.92]:40921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swu4u-0003VO-Rh for qemu-devel@nongnu.org; Thu, 02 Aug 2012 08:00:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Swu4i-00023t-Ro for qemu-devel@nongnu.org; Thu, 02 Aug 2012 08:00:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swu4i-00023J-Jq for qemu-devel@nongnu.org; Thu, 02 Aug 2012 08:00:20 -0400 Date: Thu, 2 Aug 2012 09:01:18 -0300 From: Eduardo Habkost Message-ID: <20120802120118.GD3702@otherpad.lan.raisama.net> References: <1343846728-8611-1-git-send-email-ehabkost@redhat.com> <50198BE2.4050005@suse.de> <20120801202758.GC3702@otherpad.lan.raisama.net> <87629273aj.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <87629273aj.fsf@codemonkey.ws> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 0/3] Move CPU model definitions to C List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Igor Mammedov , Andreas =?iso-8859-1?Q?F=E4rber?= , qemu-devel@nongnu.org On Wed, Aug 01, 2012 at 03:41:56PM -0500, Anthony Liguori wrote: > Eduardo Habkost writes: >=20 > > On Wed, Aug 01, 2012 at 10:04:50PM +0200, Andreas F=E4rber wrote: > >> Am 01.08.2012 20:45, schrieb Eduardo Habkost: > >> > This makes the change we discussed on the latest KVM conf call[1],= moving the > >> > existing cpudefs from cpus-x86_64.conf to the C code. > >> >=20 > >> > The config file data was converted to C using a script, available = at: > >> > https://gist.github.com/3229602 > >> >=20 > >> > Except by the extra square brackets around the CPU model names (in= dicating they > >> > are built-in models), the output of "-cpu ?dump" is exactly the sa= me before and > >> > after applying this series. > >> >=20 > >> > [1] http://article.gmane.org/gmane.comp.emulators.kvm.devel/95328 > >> >=20 > >> > Eduardo Habkost (3): > >> > i386: add missing CPUID_* constants > >> > move CPU models from cpus-x86_64.conf to C > >> > eliminate cpus-x86_64.conf file > >>=20 > >> If we do this, we will need to refactor the C code again for CPU > >> subclasses. Can't we (you) do that in one go then? :-) > > > > Why again? The refactor for classes would be a one-time mechanical > > process, won't it? > > > > Anyway, I wouldn't do it in a single step. I prefer doing things one > > small step at a time. >=20 > I tend to agree. >=20 > >> I thought there was a broad consensus not to go my declarative > >> X86CPUInfo way but to initialize CPUs imperatively as done for ARM. > >> That would mean transforming your > >>=20 > >> + { > >> + .family =3D 6, > >> + .model =3D 2, > >> ... > >>=20 > >> into an initfn doing > >>=20 > >> - { > >> +static void conroe_initfn(Object *obj) > >> +{ > >> + X86CPU *cpu =3D X86_CPU(obj); > >> + CPUX86State *env =3D &cpu->env; > >> + > >> - .family =3D 6, > >> + env->family =3D 6; > >> - .model =3D 2, > >> + env->model =3D 2; > >> ... > >>=20 > >> or so (not all being as nicely aligned). > > > > Really? I am surprised that this is the consensus. >=20 > Andreas is absolutely correct here. Obviously, it's always better to > represent things as data instead of code. The basic problem is that > this can't be easily represented as data (particularly when you start > getting into compat properties). I agree that sometimes we can't represent everything easily as data and some code is required. I just don't see yet why that would be the case for the CPU model data. The fact that we're insisting in using global properties to implement the compat code is a demonstration that it can be completely data-driven, isn't it? We also need to expose some of the CPU model information to libvirt, so we will surely need to keep some of that information available as data. >=20 > > Why would one want to > > transform machine-friendly data into a large set of opaque functions > > that look all the same and contains exactly the same data inside it, = but > > in a too verbose, machine-unfriendly and refactor-unfriendly way? It > > doesn't make sense to me. > > > > I will look for previous discussions to try to understand the reason = for > > that (was this discussed on qemu-devel?). Do you have any pointers > > handy? > > > > > >>=20 > >> Unfortunately the move of the CPU definitions from config file to C = does > >> not eliminate the issue that users can still specify CPU models in t= heir > >> own config files or from the command line, right? Doesn't that mean = that > >> either we need to keep all CPU definitions declarative as done here = and > >> live with any field duplication between X86CPUInfo and X86CPUClass, = or > >> have a special intermediate subclass UserX86CPUClass with such field= s > >> for user-specified -cpudef models? > >> Assuming, dropping -cpudef for 1.2 is still not an option. > > > > I would be happy to drop support for cpudef config sections > > completely. >=20 > Please add docs to your patch about -cpudef being deprecated. We'll re= move > it for 1.3 provided no one screams. I'll do. >=20 > I'll include something in the 1.2 release notes and ask anyone to > contact qemu-devel if they depend on this feature. >=20 > We haven't really done this in the past, but I don't see a reasonable > way to keep supporting -cpudef moving forward. >=20 > Regards, >=20 > Anthony Liguori >=20 > > The only problem is compatibility, but personally I wouldn't mind > > breaking it (I don't think many users have been writing their own > > cpudefs). > > > > Anyway, if we keep supporting it for compatibility (it could be simpl= y > > one separated CPU subclass that uses the config file data), at least = we > > don't have the need for versioning/compatibility mechanisms for > > user-provided cpudefs. > > > >>=20 > >> Regards, > >> Andreas > >>=20 > > > > --=20 > > Eduardo --=20 Eduardo