From: Eduardo Habkost Subject: Re: [qom-cpu PATCH 7/7 v9] target-i386: CPU model subclasses Date: Tue, 11 Feb 2014 06:05:57 -0200 Message-ID: <20140211080557.GP28427@otherpad.lan.raisama.net> References: <1391111339-6958-1-git-send-email-ehabkost@redhat.com> <1391111339-6958-8-git-send-email-ehabkost@redhat.com> <20140131181338.GB28427@otherpad.lan.raisama.net> <52F81C09.6070504@suse.de> <20140210081958.GN24353@otherpad.lan.raisama.net> <20140210082617.GO24353@otherpad.lan.raisama.net> <20140210102130.GP24353@otherpad.lan.raisama.net> <52F95537.40007@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, libvir-list@redhat.com, qemu-devel@nongnu.org, Paolo Bonzini , Igor Mammedov , Jiri Denemark To: Andreas =?iso-8859-1?Q?F=E4rber?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750785AbaBKIGD (ORCPT ); Tue, 11 Feb 2014 03:06:03 -0500 Content-Disposition: inline In-Reply-To: <52F95537.40007@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Feb 10, 2014 at 11:39:51PM +0100, Andreas F=E4rber wrote: > Am 10.02.2014 11:21, schrieb Eduardo Habkost: > > +static const TypeInfo x86_cpu_host_type_info =3D { > > + .name =3D CPU_CLASS_NAME("host"), > > + .parent =3D TYPE_X86_CPU, > > + .instance_size =3D sizeof(X86CPU), > > + .instance_init =3D x86_cpu_instance_init_host, > > + .abstract =3D false, > > + .class_size =3D sizeof(X86CPUClass), > > + .class_init =3D x86_cpu_class_init_host, > > +}; >=20 > This looks broken: .class_data is not set but the loading of the cpud= ef > happens in the TYPE_X86_CPU initfn. My preferred solution would be to > move the cpudef-loading from TYPE_X86_CPU's instance_init to a separa= te > one specified for the models only, allowing non-cpudef-based models. = Not > finished investigating yet. class_data is not set because x86_cpu_class_init_host doesn't use it. x86_cpu_class_init_host() simply points fills host_cpu_def and makes xcc->cpu_def point to it. Why would we need a separate instance_init only for the other models? x86_cpu_initfn() already works for everythin= g except the ->features field (that is then handled by x86_cpu_instance_init_host()). >=20 > For now I've prepended a patch implementing my generalized > CPUClass::class_by_name instead of a custom x86_cpu_class_by_name(). Sounds good to me. >=20 > Other style nits that I'm working on cleaning up are declarations in = the > middle of blocks, keeping _class_init naming convention (pretty sure = my > patches always had the most-specific-to-least-specific naming), stric= tly > distinguishing between type and class, adding to my gtk-style > documentation rather than new custom comments, placing struct > documentation in the header and keeping the diff nicely readable AFAP= =2E > I'd further like to keep some other conventions from previous CPU > subclasses, like pulling the model for loop out of the model > registration function. >=20 > My patches had always tried to turn what is now x86_cpu_load_def() in= to > an instance_init function rather than calling it from one - did you h= ave > reasons not to? I like to keep the "simply move stuff from X86CPUDefinition to X86CPU" logic in a separate place. I think it makes the code more readable (and it also made the code movements more obvious because I didn't have to move all the code that's inside load_def(), just the load_def() call. But if you want to inline it inside instance_init, I wouldn't mind. >=20 > Did you consider converting the host model in a first step to make th= e > patch smaller? Converting the host model would require moving some logic to instance_init but keeping the strcmp(name, "host") hack. I thought it would involve more complex intermediate steps so I chose not to try it. --=20 Eduardo