From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] Separate vmx/svm fields from kvm_vcpu Date: Tue, 26 Jun 2007 08:59:17 -0400 Message-ID: <46810DA5.9070301@qumranet.com> References: <46802CF0.6090100@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Jun Koi Return-path: In-Reply-To: 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 >> >> If you make this >> >> + union { >> + struct kvm_vmx_data vmx[1]; >> + struct kvm_svm_data svm[1]; >> + }; >> >> then we can later change it to a zero-sized array with variable-size >> allocation, with no additional code changes. >> > > Why do we want to make it array? I suppose that we only have 1 struct > (either vmx or svm) for each vcpu, no? > If it's an array of size one, you can refer to the only element with vcpu->vmx->member. If it's later changed to an array of size zero, you can keep the references the same, and change the allocations to kmalloc(sizeof(struct kvm_vcpu) +sizeof(struct kvm_vmx_data)) so that you don't allocate any unnecessary memory. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/