From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Otte Subject: Re: [PATCH 0 of 3] create kvm_x86 Date: Wed, 21 Nov 2007 10:39:02 +0100 Message-ID: <4743FCB6.8080404@de.ibm.com> References: <4743F5AE.8090707@de.ibm.com> <4743F7DF.4000107@qumranet.com> Reply-To: carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org, kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Xiantao , Hollis Blanchard To: Avi Kivity Return-path: In-Reply-To: <4743F7DF.4000107-atKUWr5tajBWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Avi Kivity wrote: > Well, I hate to say it, but the resulting code doesn't look too well > (all the kvm_x86 variables), and it's entirely my fault as I recommended > this approach. Not like it was difficult to predict. > > I'm thinking again of > > struct kvm { > struct kvm_arch a; > ... > } > > Where each arch defines its own kvm_arch. Now the changes look like a > bunch of "kvm->blah" to "kvm->a.blah" conversions. > > IIRC a downside was mentioned that it is easier to cause a build failure > for another arch now. > > Opinions? In theory correctness should win over style every time, no? It's a matter of taste. I favor embedding an kvm_arch too, but I recommend to name member "a" different. "arch" maybe? An advantage of this solution is, that some (not all) architectures can share common code. If kvm_arch contains member foo for x86 and ia64, a common function could do kvm->a.foo. With the posted approach, we'd have #ifdef CONFIG_ARCH_X86 val = to_kvm_x86(kvm).foo; #else val = to_kvm_ia74(kvm).foo; #endif ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/